–压缩备份导出库
–定义变量,把备份的ql脚本赋值给变量
declare @sqlbackupdatabase as nvarchar(1000)
set @sqlbackupdatabase=n’backup database cyyfhis_20180201 to disk = ”d:\cyyfhis_20180201-‘+
convert(varchar(11),getdate(),112)+replace(convert(varchar(12),getdate(),108),’:’,”)+’.bak”’
+’with stats = 1,compression’
–备份文件格式:northwind-20170111132424.bak
exec sp_executesql @sqlbackupdatabase –调用存储过程,执行sql