(SQL Server) bz2 Compress File
Compress a file to the bz2 file format.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @bz2 int
-- Use "Chilkat_9_5_0.Bz2" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Bz2', @bz2 OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
DECLARE @success int
EXEC sp_OAMethod @bz2, 'CompressFile', @success OUT, 'qa_data/hamlet.xml', 'qa_output/hamlet.bz2'
IF @success <> 1
BEGIN
EXEC sp_OAGetProperty @bz2, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @bz2
RETURN
END
PRINT 'Success.'
EXEC @hr = sp_OADestroy @bz2
END
GO
|