SQL Server
SQL Server
Compute CRC32 of a File
Calculates the CRC32 of a file's contents and returns the 32-bit CRC as a hex string.Chilkat SQL Server Downloads
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @zipCrc int
EXEC @hr = sp_OACreate 'Chilkat.ZipCrc', @zipCrc OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Use a relative for absolute path to the file..
DECLARE @crc int
EXEC sp_OAMethod @zipCrc, 'FileCrc', @crc OUT, 'qa_data/hamlet.xml'
DECLARE @hexStr nvarchar(4000)
EXEC sp_OAMethod @zipCrc, 'ToHex', @hexStr OUT, @crc
PRINT @hexStr
EXEC @hr = sp_OADestroy @zipCrc
END
GO