Sample code for 30+ languages & platforms
SQL Server

Decode Base64

Demonstrates how to decode base64.

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 @bd int
    EXEC @hr = sp_OACreate 'Chilkat.BinData', @bd OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    -- Append a base64 string to bd.
    EXEC sp_OAMethod @bd, 'AppendEncoded', @success OUT, 'c2VjcmV0', 'base64'

    -- The bd now contains the decoded bytes.
    -- Let's say it was a password string..
    DECLARE @password nvarchar(4000)
    EXEC sp_OAMethod @bd, 'GetString', @password OUT, 'utf-8'

    -- Decodes to "secret".

    PRINT 'password = ' + @password

    EXEC @hr = sp_OADestroy @bd


END
GO