Select to view content in your preferred language

Convert VARBINARY (BLOB) to Base64 String using T-SQL

12362
2
07-12-2017 06:35 AM
TL2
by
Frequent Contributor

I am trying to convert the attachment tables DATA tab (BLOB/VARBINARY) into Base64.  

USE UTILITIES
SELECT CAST(CAST('' as XML).value('xs:base64Binary(sql:column("DATA"))', 'VARBINARY(MAX)') AS NVARCHAR(MAX))

FROM FeatureClass_ATTACH_evw
WHERE REL_OBJECTID = '51'
go

Results:

"�က䙊䙉Ā ĀĀ"

Is there a way to convert the BLOB into Base64?

Tags (2)
0 Kudos
2 Replies
DavidBuehler
Frequent Contributor

Did you figure this out?

0 Kudos
TL2
by
Frequent Contributor

Kind of.... I was able to get it to work but only with images the size of thumbnails.  Anything "large" would get cut off about 1 inches from the top.  

From what I read on the WWW it should work with normal sized images.  The string for a base64 is very large (but is under the varchar(max) limit)