--备份(按日期备份)
declare @name varchar(50)
declare @name1 varchar(50)
--获取当前日期
select @name=replace(CONVERT(varchar(100),getdate(), 23),'-','_')
--备份地址
set @name1 ='D:\Double-Backup\InventoryWX_'+@name+'.bak'
--数据文件
BACKUP DATABASE [InventoryWX] TO
DISK = @name1
WITH NOFORMAT, INIT, NAME = N'InventoryWX-完整数据库 备份',
SKIP, NOREWIND, NOUNLOAD, STATS = 10
--日志文件
set @name1 ='D:\Double-Backup\InventoryWX_'+@name+'.trn'
BACKUP LOG [InventoryWX]
TO DISK = @name1
WITH NOFORMAT, INIT, NAME = N'InventoryWX-事务日志 备份',
SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO