Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 3rd, 2005, 05:46 AM
Authorized User
Join Date: Jan 2005
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.

Old February 3rd, 2005, 06:20 AM
Friend of Wrox
Join Date: Jun 2003
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.
Old February 3rd, 2005, 07:28 AM
Authorized User
Join Date: Jan 2005
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
Old February 3rd, 2005, 07:54 PM
Authorized User
Join Date: Feb 2005
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.


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 07: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 08: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 09:02 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.