SELECT CONVERT ( VARCHAR(MAX), CAST('' AS XML).value('xs:base64Binary(sql:column("BASE64_COLUMN"))', 'VARBINARY(MAX)') ) AS RESULT FROM ( SELECT 'cm9sZToxIHByb2R1Y2VyOjEyIHRpbWVzdGFtcDoxNDY4NjQwMjIyNTcxMDAwIGxhdGxuZ3tsYXRpdHVkZV9lNzo0MTY5ODkzOTQgbG9uZ2l0dWRlX2U3Oi03Mzg5NjYyMTB9IHJhZGl1czoxOTc2NA==' AS BASE64_COLUMN ) A
もし、taというテーブルでcol1にデコードしたい場合は以下でデコードできた
select id, col1, CONVERT ( VARCHAR(MAX), CAST('' AS XML).value('xs:base64Binary(sql:column("col1"))', 'VARBINARY(MAX)') ) AS RESULT from ta
Decode Base64 String Natively in SQL Server
I have a varchar column in a table in SQL Server that holds a Base64-encoded text string, which I would like to decode i...