Reputation: 1143
I have a SQL table with varbinary type column and I stored PDF File in it. This is how the file looks in database:
0x4D007900500044004600460069006C0065002E00700064006600
How do I convert it so that I can see PDF file's content?
For example: In same column I stored XML file and I can see the XML file content by using CONVERT()
function:
SELECT *, CONVERT(XML,(CONVERT(varbinary(max),[fileColumn]))) from table
Upvotes: 1
Views: 9390
Reputation: 61839
It doesn't need converting as such - the data is already PDF data, as you stated yourself. You just need to put it somewhere where a program which knows how to display PDF data can read and understand it.
As the above comment notes, the easiest way to achieve that is by putting it into a file. Then you can open it in Adobe Reader or other PDF program of your choice.
SQL itself (or to be precise, any SQL Server client software that I know of) cannot render PDFs to the screen directly, if that's what you're asking.
P.S. The key difference between that and your XML example is that XML is a text-based format (whereas PDF is binary), and also SQL Server has a built-in understanding of XML already, so it's easy for a) SQL to parse the data using its built-in functions, and b) a SQL client to display it, because it's already able to display text.
Upvotes: 3