--建立備份裝置
USE [master]
GO
EXEC master.dbo.sp_addumpdevice @devtype = N'disk', @logicalname = N'beifen', @physicalname = N'D:\beifen.bak'
GO
--完整備份到備份裝置中
BACKUP DATABASE [student] TO [beifen] WITH NOFORMAT, NOINIT, NAME = N'student-完整 資料庫 備份', SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO
--還原完整備份
RESTORE DATABASE [student] FROM [beifen] WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10
GO
--差異備份
BACKUP DATABASE [student] TO [beifen] WITH DIFFERENTIAL , NOFORMAT, NOINIT, NAME = N'student-差異 資料庫 備份', SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO
--交易記錄備份
BACKUP LOG [student] TO [beifen] WITH NOFORMAT, NOINIT, NAME = N'student-交易記錄 備份', SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO
--還原到最近狀態
RESTORE DATABASE [student] FROM [beifen] WITH FILE = 1, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE DATABASE [student] FROM [beifen] WITH FILE = 2, NORECOVERY, NOUNLOAD, STATS = 10
GO
RESTORE LOG [student] FROM [beifen] WITH FILE = 3, NOUNLOAD, STATS = 10
GO
本文來自CSDN部落格,轉載請標明出處:http://blog.csdn.net/qq49121294/archive/2009/03/24/4019637.aspx