Lauren Buxton Lauren Buxton - 1 year ago 73
SQL Question

Can you generate xml feeds in ssms with images/pictures

I am designing my database to hold records of user profiles.

These user profiles have the standard: title, name, biography and each have a picture which I need save in the table also


I need to generate an XML output for the web developer to use in the website, is it possible to send this image in the XML or will he need these picture in a location he can access?

Hope this makes sense.

Thanks, Lauren

Answer Source

Don't know if it is this what you need, but SQL-Server's FOR XML PATH() will encode a binary value as Base64 implicitly:

SELECT 'The Title' AS [@Title]
      ,'The Name' AS [@Name]
      ,0x1234567890ABCDEF AS [Base64EncodedBinary]

The result

<Test Title="The Title" Name="The Name">

This Base64-string can be used as <img>-source directly...


This would need SQL-Server 2008+. Earlier version 2005 encoded binaries to a HEX-string implicitly...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download