RESTORE FILELISTONLY FROM DISK = N'C:\[path]\[db_name_backup].bak' GO
This shows LogicalName and PhysicalName of the data and log backup files, which have to be used in the following script:
RESTORE DATABASE [db_name] FROM DISK = N'C:\[path]\[db_name_backup].bak' WITH FILE = 1, MOVE N'[data_file_logical_name]' TO N'C:\[restored_db_path]\[data_file_name].mdf', MOVE N'[log_file_logical_name]' TO N'C:\[restored_db_path]\[log_file_name].ldf', NOUNLOAD, STATS = 10 GO
If you like myself do not like clicking through SQL Server Management Studio GUI, this script can help you automate database restore process.
No comments:
Post a Comment