473,387 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Database backup in Perl

I am new to perl
but after spending late nights for some days , i was able to generate code for database backup. the code will ask you enter servername , enter database name if i enter it will take backup
suppose my code is in backup.pl
now the thing is i need to get database backup by entering like this perl backup.pl -i servername -d databasename
if i hit enter it should take backup of given server name and database name.

My code:
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use Win32::SqlServer qw(SCALAR);
  3.  
  4. print "Please enter DB name:\n";
  5. my $name = <STDIN>;
  6. chomp($name);
  7. # Log in to  server .
  8.  
  9. my $sqlsrv = Win32::SqlServer::sql_init('localhost', 'geff', 'gentle', 'Northwind');
  10. # Our SQL statement.
  11.  
  12. my $stmnt = <<SQLEND;
  13. BACKUP database  "$name" TO  DISK = N'c:\\bak\\master.dmp'  
  14. SQLEND
  15.  
  16. # Run query. 
  17. my $result = $sqlsrv->sql($stmnt, SCALAR);
  18.  
  19. # Print results.
  20. foreach my $name (@$result) {
  21.    print "$name\n";
  22. }
  23.  
Jan 19 '12 #1
1 1714
RonB
589 Expert Mod 512MB
Answered here on the cross post: http://forums.devshed.com/perl-progr...es-877805.html
Jan 19 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: santanu | last post by:
Hi all, I know a little python (not the OOP part) learnt by studying the online tutorial. Now I would like to learn it more thoroughly. I have access to 'Programming Python' which I liked...
2
by: Joao Santa Barbara | last post by:
Hi all i have this error reading one registry key , can anyone assist me .. please very urgent i try in one computer, and work fine, but in other computer it didnīt work and throws this error...
1
by: Support | last post by:
We are a large organization with a number of offices all over the state. All our employees need to access data/update data and generate reports from all offices. Initially our application will...
2
by: anton.aleksandrov | last post by:
Hello, First of all - sorry for may be stupid question, but as I am not a Win* administrator and my field is *nix, I am a little bit stuck with a problem, presented to me by one of the customers....
3
by: ashutosh | last post by:
I am working for a company and working for printer drivers. Most of the work is in ddk, VC++ and C++, gdi calls. I have studied C++ and ddk and VC++ is new for me. Can anybody suggest me some good...
3
by: srikar | last post by:
Hi can any one tell me If we want to print the adress of the object if I type cast in to int on a machine where address and int occupies same size it is not be a problem. If on a machine where...
2
by: astarter | last post by:
Hello friends. I am second year student of Computer engg. in DCE. I want to make some project to hone my programming skills. Please suggest some. I know C,C++, Java( core only) and DS. Any help...
2
by: only2gayathri | last post by:
Hi all, I have a page(vb.net) which directs to a excel sheet.This excel sheet retains all the values(mainly numbers) from the page and displays it.The problem is that sometimes the number's...
2
by: nethravathy | last post by:
Hi, The following table namely elcbtripselect contains 5147 records.I want to know wether this table contains duplicate records or not. I tried with following query 1)SELECT...
3
by: Martin Wells | last post by:
I'm doing an embedded systems college project this year. I making a portable device that will take input in the form of simple switches, and give output in the form of LED's. I haven't yet decided...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.