SQL数据库压缩 7z
DECLARE @myBakName VARCHAR(4000)
DECLARE @myBak VARCHAR(4000)
DECLARE @mydbname VARCHAR(4000)
DECLARE @mydbPath VARCHAR(4000)
DECLARE @myFullPath VARCHAR(4000)
DECLARE @myCompressorPath VARCHAR(4000)
DECLARE @myCompressorFile VARCHAR(4000)
SET @mydbname = 'TjCar_20081216'
SET @mydbPath = 'D:\Projects.Databases\BACKUP\'
SET @myCompressorPath = 'C:\Progra~1\7-Zip\'
SET @myBakName = @mydbPath
+ @mydbname
+ '_'
+ CONVERT(CHAR(8),Getdate(),112)
+ '_'
+ REPLACE(CONVERT(CHAR(8),Getdate(),108),':','')
SET @myCompressorFile = @myBakName + '.7z'
SET @myBak = @myBakName + '.bak'
BACKUP database @mydbname to disk=@myBak with init
SET @myFullPath = @myCompressorPath + '7z.exe a ' + @myCompressorFile + ' ' + @myBak
exec master..xp_cmdshell @myFullPath