Sample code for 30+ languages & platforms
SQL Server

Load utf-8 Text File into a StringBuilder

Demonstrates how to load a utf-8 text file into a StringBuilder object instance.

Chilkat SQL Server Downloads

SQL Server
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @success int
    SELECT @success = 0

    DECLARE @sb int
    EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sb OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OAMethod @sb, 'LoadFile', @success OUT, 'someFileContainingUtf8.txt', 'utf-8'
    IF @success <> 1
      BEGIN

        PRINT 'Failed.'
      END
    ELSE
      BEGIN

        PRINT 'Success.'
      END

    EXEC @hr = sp_OADestroy @sb


END
GO