SQL定时删除过期备份
时间:2011-04-18 来源:一路前行
a
Declare @FileName varchar(100)
Set @FileName='D:\数据备份\' + convert(varchar(10),getdate(),120)+ '.bak'
BackUp Database CoalTraffic To Disk=@FileName
With Init b --差异备份(必须与完整备份同名)
Declare @FileName varchar(100)
Set @FileName='D:\数据备份\' + convert(varchar(10),getdate(),120)+ '.bak'
Backup database CoalTraffic To Disk=@FileName
With Differential c
--删除创建时间为@CreateDate,类型为BAK的文件 --与BAK的文件名没有关系
declare @CreateDate datetime
select @CreateDate=getdate()-1
EXECUTE master.dbo.xp_delete_file 0,N'D:\数据备份\',N'BAK',@CreateDate
相关阅读 更多 +