Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert SQL Server varbinary field to string?

I have a column in a sql server 2005 database that stores xml as varbinary, the value lookes something like:

0x3C3F54657374696E672075706C6F616 // but much longer

Is there an online conversion tool for converting this to a readable string?

like image 889
Peter Avatar asked Feb 25 '23 11:02

Peter


1 Answers

select CAST(0x3C3F54657374696E672075706C6F61643F3E3C666F6F3E3C2F666F6F3E as XML)

appears to work.

Online Conversion Link

And as it seems your datatype is image...

;with t(c) as
(
select CAST(0x3C3F54657374696E672075706C6F61643F3E3C666F6F3E3C2F666F6F3E as IMAGE)

)
select CAST(CAST(c as VARBINARY(MAX)) as XML)
from t
like image 134
Martin Smith Avatar answered Feb 27 '23 05:02

Martin Smith