Archives by Tag 'SQL & DB'

SQL 2005 BASE64 Decode Query Syntax

By admin - Last updated: Thursday, August 21, 2008

Decode BASE64 encoded string SQL query syntax — declare vars. DECLARE @data varchar(max), @XmlData xml — set the base64 encoded varchar. SET @data = ‘SGVsbG8gV29ybGQgIQ==’ — construct an xml var. SET @XmlData = CAST(‘<data>’ + @data + ‘</data>’ as xml) — base64 decode the @data. SELECT   CONVERT(varchar(max),        @XmlData.value(‘(data)[1]‘, ‘varbinary(max)’))