sql 压缩文件(rar或zip)
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[p_ZipFile]
@xlspath nvarchar(4000)
,@outpath nvarchar(4000)
as
/*
declare @xlspath nvarchar(4000)
declare @outpath nvarchar(4000)
select @xlspath='D:\WebRoot\test123.xls'
select @outpath='D:\WebRoot\test123.rar'
*/
declare @cmd nvarchar(4000)
--select @cmd='""%ProgramFiles%\WinZip\Wzzip.exe"" -m -j
'+@outpath+' ' + @xlspath --zip(!!!Note: Must install WINZIP and WinZip Command Line Support Add-On)
select @cmd='""%ProgramFiles%\WinRAR\Rar.exe"" a -ep1 -df
'+@outpath+' ' + @xlspath --rar
print @cmd
exec master..xp_cmdshell @cmd