SQL server data base restore script

Published Friday, July 03, 2009 7:29 AM

this is a quick trick that i googled from bits and pieces in a caffe when my laptop didn’t have a Management studio installed

i found a way to execute sql scripts to my instance of sql express

well to restore you need to have the logical names of files in the database backup to know that

just type

RESTORE FILELISTONLY
FROM DISK = ‘<path to your backup file>’

this will display all the logical file’s in the backup in the result sets

you’ll need the logical file names for the coming script (the actual restore)

 

RESTORE DATABASE <DataBaseName>
FROM DISK = ‘<path to your backup file>’
WITH MOVE ‘<Data file logical Name>’ TO '<path to resotre your datafile>',
MOVE '<log file logical name >' TO '<path to restore your log file>'

 

Filed under: ,

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required)