Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backup & Restore Database

Status
Not open for further replies.

woohahee

MIS
Mar 2, 2001
16
GB
ok I'm trying to Backup my database to disk, then restore the database to the same server but under a new name

Please can someone help me with this.

My code so far:

BACKUP DATABASE master TO DISK = 'D:\archive.bak'
DROP DATABASE archive
CREATE DATABASE archive
RESTORE DATABASE archive FROM DISK = 'D:\archive.bak'

Now this doesn't work because I need to use the WITH REPLACE overwrite option

None of my help resources even mention this as an option.

Please help,

Richard
 
With move is well documented in SQL BOL.
Here is an example. You may need to change some of the paths or file names for your system. You do not need to create the datbase before restorin.

BACKUP DATABASE master TO DISK = 'D:\archive.bak'
DROP DATABASE archive
RESTORE DATABASE archive FROM DISK = 'D:\archive.bak'
With Move 'master' To 'd:\mssql7\data\archive_data.mdf',
Move 'mastlog' To 'd:\mssql7\data\archive_log.ldf'

Terry L. Broadbent - Salt Lake City, UT
Home of the 2002 Winter Olympics (Feb 8-24)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top