1、首先还原一个全备
RESTORE DATABASE SWJSWMES FROM DISK= 'D:\XXX.BAK' WITH MOVE N'XXX' TO N'D:\Backup\XXX.ndf', MOVE N'XXX_log' TO N'D:\Backup\XXX_log.ldf', NORECOVERY
2、根据增量备份文件日期,接着循环恢复数据库
DECLARE @i int = 0 DECLARE @path NVARCHAR(MAX) WHILE (@i <= 6)--有几个文件就恢复几个文件 BEGIN SELECT @path = 'D:\XXX'+RIGHT('00'+CONVERT(varchar(10),@i),2)+'.BAK' --PRINT @path RESTORE DATABASE XXX FROM DISK = @path WITH NORECOVERY SET @i = @i + 1 END
3、还原到想还原时间点前一个备份文件,然后在设置时间点恢复数据
RESTORE LOG SWJSWMES FROM DISK =N'D:\XXX.BAK'--这个是要恢复的文件,包含想要恢复时间点的数据 WITH FILE = 1, STANDBY = N'D:\XXX.BAK', --这个地址随便设置 STOPAT = N' 2022-10-25 09:00:00.000' GO
标签:MOVE,备份,XXX,数据库,还原,Sql,备份文件,BAK From: https://www.cnblogs.com/weifeng123/p/16827152.html