I have some varbinary data stored in a table in MS Sql Server 2005. Does anyone have SQL code that takes a query as input (lets say the query guarantees that a single colum
You can use BCP, not T-SQL, but works well.
BCP "SELECT FileContent FROM table WHERE ID = 1" queryout "C:\file.txt" -T
Just an alternative. You can use the freeware Toad for SQL server and save directly from the editor.
You can go to their website https://www.toadworld.com and get the freeware there or a 30 day trial of the full version. Its under Download and pick Toad for SQL server.
You do a regular select statement in Toad on the line that has the image you want to save. When you see the results you can click on the byte image column and on the right you see a PDF tab if this is a PDF document or on the left you see a Image tab. When you click the tab you can see the save logo at the bottom to save the image or file.