產生還原資料庫指令碼的程序如下
1. 開啟Microsoft SQL Server Management Studio
2. 在要還原的資料庫上右鍵->工作->還原->資料庫
3. 在[還原資料庫-MyDB]視窗中的確認以下相關資訊(如下圖所示)後按下[指令碼]
a. [目的地資料庫]
b .[來源資料庫]
c. [選擇要還原的備份組]:勾選要還原的項目
4.就可以產生以下的指令碼,天啊~如果要自己寫是多麼痛苦的事情啊
RESTORE DATABASE [MyDB] FROM DISK = N'H:\DB_Backup\MyDB_backup_2013_10_02_220001_1783058.bak' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_02_230000_9407058.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_000001_6391058.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_010001_5991547.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_020001_2523547.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_030000_9679547.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_040001_7287547.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_050001_4131547.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_060001_0507547.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_070000_8443547.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_080001_5427547.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_090001_7419547.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_100001_5938796.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_110001_3406796.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_120001_1342796.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_130000_7874796.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_140001_5014796.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_150001_2170796.trn' WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [MyDB] FROM DISK = N'H:\DB_Backup\MyDB\MyDB_backup_2013_10_03_160000_9638796.trn' WITH FILE = 1, NOUNLOAD, STATS = 10
GO
附註:使用這項功能當然有些限制的
1. MSDB資料庫是OK的。
2. 要還原的資料庫日期存在備份組中,例如要還原的資料庫時間已超過備份組的時間,那就沒辦法做到。
3. 所以還是自己寫隻Restore程式或許會更方便。
沒有留言:
張貼留言