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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restore Database SQL Script

Status
Not open for further replies.

dgrover

MIS
Jan 13, 2004
1
US
I'd like to automate the restore of a production database back-up to another database for reporting purposes. Does anyone have a sample script they'd be willing to share?
 
RESTORE DATABASE { database_name | @database_name_var }
[ FROM < backup_device > [ ,...n ] ]
[ WITH
[ RESTRICTED_USER ]
[ [ , ] FILE = { file_number | @file_number } ]
[ [ , ] PASSWORD= { password | @password_variable } ]
[ [ , ] MEDIANAME= { media_name | @media_name_variable } ]
[ [ , ] MEDIAPASSWORD= { mediapassword | @mediapassword_variable } ]
[ [ , ] MOVE 'logical_file_name' TO 'operating_system_file_name' ]
[ ,...n ]
[ [ , ] KEEP_REPLICATION ]
[ [ , ] { NORECOVERY | RECOVERY | STANDBY =undo_file_name } ]
[ [ , ] { NOREWIND | REWIND } ]
[ [ , ] { NOUNLOAD | UNLOAD } ]
[ [ , ] REPLACE ]
[ [ , ] RESTART ]
[ [ , ] STATS [ =percentage ] ]


SO ...

RESTORE DATABASE MyDatabase
FROM TAPE = '\\.\Tape0' -- From Tape
FROM DISK = 'C:\MyDir\MyDatabase.bak'

Thanks

J. Kusch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top