sql cast varchar to base64 code example
Example: base64 encode sql server
--String to Base64
SELECT CAST('string' as varbinary(max)) FOR XML PATH(''), BINARY BASE64
--Base64 to String
SELECT CAST( CAST( 'c3RyaW5n' as XML ).value('.','varbinary(max)') AS varchar(max) )