--事务日志备份
BACKUP LOG [testbak] TO  DISK = N'C:\Data2\test.bak'
WITH NOFORMAT, NOINIT,  NAME = N'testbak-事务日志  备份',
SKIP, NOREWIND, NOUNLOAD,  STATS = 10

--设置单个用户
ALTER DATABASE [testbak] SET  SINGLE_USER WITH ROLLBACK IMMEDIATE

ALTER DATABASE [testbak] SET  SINGLE_USER

--尾日志备份
BACKUP LOG [testbak] TO  DISK = N'C:\Data2\test.bak'
WITH  NO_TRUNCATE , NOFORMAT, NOINIT,  NAME = N'testbak-事务日志  备份',
SKIP, NOREWIND, NOUNLOAD,  NORECOVERY ,  STATS = 10

--还原完整备份
RESTORE DATABASE [testbak] FROM  DISK = N'C:\Data2\test.bak' WITH  FILE = 1,  NOUNLOAD,  STATS = 10
--还原完整备份
restore database testbak from   disk ='C:\Data2\test.bak' with file=1,norecovery,nounload,replace,stats=10;
--还原事务日志
restore log testbak from   disk ='C:\Data2\test.bak' with file=2,norecovery,nounload,stats=10;
restore log testbak from   disk ='C:\Data2\test.bak' with file=3,norecovery,nounload,stats=10;

restore log testbak from   disk ='C:\Data2\test.bak' with file=4,norecovery,nounload,stats=10;
--还原最后一个日志
restore log testbak from   disk ='C:\Data2\test.bak' with file=5,nounload,stats=10;
--查看备份日志是否前后连接
restore headeronly from disk ='C:\Data2\test.bak'

posted on 2010-07-22 23:19  自由港  阅读(278)  评论(0编辑  收藏  举报