Sqlserver 差异备份
declare @fileName varchar(100)
//每个星期完整备份一次,产生一个文件,在代理作业中,每天执行一次
select @fileName='e:\DataBase_差异备份\utsl_'+CONVERT(varchar(10), DATEADD(d, -DATEPART(w,getdate())+1,getdate()),12)+'_diff.bak'
declare @fileExist int
exec xp_fileexist @fileName, @fileExist output
if @fileExist=0 --完全备份
begin
backup database
DataBase to disk = @fileName
end
else --差异备份
begin
backup database
DataBase to disk = @fileName
WITH DIFFERENTIAL
end