Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old February 3rd, 2005, 04:46 AM
Authorized User
Join Date: Jan 2005
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL Server 2000 backup from command line

Hi ,

How can I perform backup of SQL server database by just specifying parameters (like the database name and media etc) dynamically in either a batchfile / command line ?

If the User is not willing to use EM or TSQL, is it possible to automate the process using scripts where just the database name is changed and the backup is performed (by running a batch file or the script).

Thanks in Advance.

Reply With Quote
  #2 (permalink)  
Old February 3rd, 2005, 05:20 AM
Friend of Wrox
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post

how about using the sqlmaint command-line utility - look it up in BOL, you can do backup and lots more with it.
Reply With Quote
  #3 (permalink)  
Old February 3rd, 2005, 06:28 AM
Authorized User
Join Date: Jan 2005
Location: Delhi, Delhi, India.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts

How to create a database backup (Transact-SQL)
To create a database backup

Execute the BACKUP DATABASE statement to create the database backup, specifying:
The name of the database to back up.

The backup device where the database backup will be written.
Optionally, specify:
The INIT clause to overwrite the backup media, and write the backup as the first file on the backup media. If no existing media header exists, one is automatically written.

The SKIP and INIT clauses to overwrite the backup media even if there are either backups on the backup media that have not yet expired, or the media name does not match the name on the backup media.

The FORMAT clause when using media for the first time to completely initialize the backup media and rewrite any existing media header.
The INIT clause is not required if the FORMAT clause is specified.

Important Use extreme caution when using the FORMAT or INIT clauses of the BACKUP statement, as this will destroy any backups previously stored on the backup media.

This example backs up the entire MyNwind database to tape:

USE MyNwind
   TO TAPE = '\\.\Tape0'
   NAME = 'Full Backup of MyNwind'

Amit Jain
Sr. Software Engineer
Reply With Quote
  #4 (permalink)  
Old February 3rd, 2005, 06:54 PM
Authorized User
Join Date: Feb 2005
Location: Sydney, NSW, Australia.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts

Example: Back up the entire MyNwind database

This example creates a logical backup device in which a full backup of the MyNwind database is placed.

-- Create a logical backup device for the full MyNwind backup.
USE master
EXEC sp_addumpdevice 'disk', 'MyNwind_1',
   DISK ='c:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\MyNwind_1.dat'

-- Back up the full MyNwind database.

You can copy this into a .sql file and run from the command prompt using isql commands.

Please do a test before applying on production.


Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How i can Backup and Restore Sql Server Database hamor ASP.NET 2.0 Professional 1 April 24th, 2007 07:03 AM
How to Backup database - SQL Server 2000 cancer10 SQL Language 2 March 1st, 2007 06:21 AM
How to take SQL Server Database Backup via .NET?? savan_thakkar ASP.NET 1.0 and 1.1 Professional 9 February 22nd, 2006 07:01 AM
sql server database backup by script mateenmohd SQL Server 2000 4 July 6th, 2004 12:32 PM
SQL Server Backup Restore zaeem Classic ASP Databases 0 December 4th, 2003 08:02 AM

All times are GMT -4. The time now is 04:54 AM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.