标签:
首先恢复时一个完整的备份,但在完整的备份里一定要选择with nonerecovery(企业管理器里选项中是第2项)
sql 语句是:
restore database mydata from disk = ‘c:\temp\movedb.bak‘ with norecovery
这时数据库就会变成恢复模式,这样你就可以一条一条的把trn文件添加进行恢复了.
语句是:
restore log Mydata from disk = "D:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\data\data_tlog_200407290022.TRN" with norecovery
当你恢复到你想要的数据时,再把数据库变成正常的模式就可以.
语句为:
restore log Mydata from disk = "D:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\data\data_tlog_200407290022.TRN" with recovery
这样就可以在你的备用的机器上把数据恢复到某个时间点了.
/* 下面使用游标示例 */ declare @pathname varchar(200) DECLARE vendor_cursor CURSOR FOR SELECT ‘D:\XXXX\WWWW\‘+ttttt FROM test OPEN vendor_cursor FETCH NEXT FROM vendor_cursor INTO @pathname WHILE @@FETCH_STATUS = 0 BEGIN restore log Mydata from disk = @pathname with norecovery FETCH NEXT FROM vendor_cursor INTO @pathname END CLOSE vendor_cursor
原文地址:http://www.jianfangkk.com/sqlserver/201601/275
如何通过trn日志文件恢复SQL Server 事务日志 还原 备份
标签:
原文地址:http://www.cnblogs.com/jianfangkk/p/5107866.html