標籤:blog http ar os sp 檔案 資料 on art
--返回由備份組內自主資料庫和記錄檔列表組成的結果集。
--主要獲得邏輯檔案名稱
USE master
RESTORE FILELISTONLY
FROM DISK = ‘g:\back.Bak‘
Go
************************************************
/**//*
利用bak恢複資料庫,強制還原(REPLACE)
STATS = 10 每完成10%顯示一條記錄
DBTest和DBTest_log是上面g:\back.Bak裡的邏輯檔案
*/
USE master
RESTORE DATABASE DB
FROM DISK = ‘g:\back.Bak‘
WITH MOVE ‘DBTest‘ TO ‘E:\Program Files\Microsoft SQL Server2005\Data\DB.mdf‘,
MOVE ‘DBTest_log‘ TO ‘E:\Program Files\Microsoft SQL Server2005\Data\DB_log.ldf‘,
STATS = 10, REPLACE
GO
++++++++++++++++++++++++++++++++
/**//*
備份資料DB 到.bak檔案。然後利用此bak檔案恢複一個新的資料庫DBTest。
*/
USE master
BACKUP DATABASE DB
TO DISK = ‘g:\DBBack0930.bak‘
RESTORE FILELISTONLY
FROM DISK = ‘g:\DBBack0930.bak‘
RESTORE DATABASE DBTest
FROM DISK = ‘g:\DBBack0930.bak‘
WITH MOVE ‘DBTest‘ TO ‘E:\Program Files\Microsoft SQL Server2005\Data\DBTest.mdf‘,
MOVE ‘DBTest_log‘ TO ‘E:\Program Files\Microsoft SQL Server2005\Data\DBTest_log.ldf‘
GO
---******************************
Sql Server Restore Script-1