Extract Binary Data from SQL Server using T-SQL
I have a database to which I upload files (such as PDFs, images, etc). I save these to the database as Varbinary (max).
I upload these files using C# MVC. What I was开发者_开发知识库 wondering is how can I view these files using a T-SQL query, not .net.
Is this possible?
Not directly.
Why don't you write a simple viewer application?
There are free and commercial ones out there. I haven't used this one, but it does have a trial version: SQL Image Viewer
No, you need to extract the files in order to view them.
SQL Server and SSMS (SQL Server Management Studio) don't have a facility to view binary data in this way.
You can use the sp_OAxxxx functions (the COM interaction functions) to create the appropriate viewers, but ultimately these viewer will require the data written to disk.
精彩评论