还原数据库文件组的时候出现下面的错误:
Msg 3159, Level 16, State 1, Line 1
The tail of the log for the database "testfile" has not been backedup. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you donot want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTOREstatement to just overwrite the contents of the log.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
解决这个问题有两个方法:
1. 备份尾日志:如果数据库遇到问题,并且确定尾部日志有一些需要的信息,这时备份尾部日志非常有用。
--backup primaryfilegroup
backup database [testfile] FILEGROUP= N'PRIMARY' TO DISK =N'd:\Primary.bak'
--backupsecondary filegroup
backup database [testfile] FILEGROUP= N'test1' TO DISK =N'd:\secondeary.bak'
--backup log
backup log [testfile]to disk ='d:\log.trn'
--backup taillog
backup log [testfile]to disk ='d:\log1.trn' withnorecovery
--restoreprimary filegroup
restore database testfile filegroup='PRIMARY' from DISK =N'd:\Primary.bak' withnorecovery
--restoresecondary filegroup
restore database testfile filegroup='test1' from DISK =N'd:\secondeary.bak'withnorecovery
--restore firstlog with norecovery
RESTORE LOG [testfile]FROM DISK = N'd:\log.trn' WITH FILE = 1, norecovery, NOUNLOAD, STATS= 10
--restore taillog with recovery
RESTORE LOG [testfile]FROM DISK = N'd:\log1.trn' WITH FILE = 1, recovery, NOUNLOAD, STATS= 10
2. 如果不能备份日志尾部,则使用 RESTORE语句中的WITH STOPAT 或 WITH REPLACE子句。
--backup primaryfilegroup
backup database [testfile] FILEGROUP= N'PRIMARY' TO DISK =N'd:\Primary.bak'
--backupsecondary filegroup
backup database [testfile] FILEGROUP= N'test1' TO DISK =N'd:\secondeary.bak'
--backup log
backup log [testfile]to disk ='d:\log.trn'
--restoreprimary filegroup
restore database testfile filegroup='PRIMARY' from DISK =N'd:\Primary.bak' withreplace,norecovery
--restoresecondary filegroup
restore database testfile filegroup='test1' from DISK =N'd:\secondeary.bak'withnorecovery
--restore firstlog with norecovery
RESTORE LOG [testfile]FROM DISK = N'd:\log.trn' WITH FILE = 1, recovery, NOUNLOAD, STATS= 10
更多信息参考:MSSQLSERVER_3159http://msdn.microsoft.com/en-us/library/bb283410.aspx