MS2000 差异备份 还原
--查询文件是否存在
CREATE TABLE #tmp ([File Exists] BIT, [File is a Directory] BIT, [Parent Directory Exists] BIT)
INSERT INTO #tmp ([File Exists], [File is a Directory], [Parent Directory Exists])
EXEC master.dbo.xp_fileexist 'D:\Test.bak'
SELECT * FROM #tmp
DROP TABLE #tmp
--完整备份数据库
BACKUP DATABASE MyBakTest TO DISK='D:\Test.bak' WITH FORMAT
--对tb表插入第一条记录
INSERT INTO tb_user(uname) VALUES('第一1次差异备份')
--第一次差异备份
BACKUP DATABASE MyBakTest TO DISK='D:\Test_One_Dif.bak' WITH FORMAT,DIFFERENTIAL
--对tb表插入第二条记录
INSERT INTO tb_user(uname) VALUES('第二3次差异备份')
--第二次差异备份
BACKUP DATABASE MyBakTest TO DISK='D:\Test_Two_Dif.bak' WITH FORMAT,DIFFERENTIAL
--OK.现在直接还原.完整备份+第二次差异备份.看看第二条记录在不在.
GO
--完整备份还原
RESTORE DATABASE MyBackTest2 FROM DISK='D:\Test.bak' WITH REPLACE,NORECOVERY
RESTORE DATABASE MyBackTest2 FROM DISK='D:\Test_one_Dif.bak' WITH RECOVERY
--第二次差异备份还原
RESTORE DATABASE MyBackTest2 FROM DISK='D:\Test_Two_Dif.bak' WITH RECOVERY