0

I have a table of data, one column contains images. I am trying to extract an individual records image column and export to image file using BCP. My code is as follows:

bcp "SELECT PictureData FROM BigTable WHERE RecordId='ASDF-QWER' queryout "C:\Path\File.jpg" -n -SCONNECTION\STRING -T

The output after running the command appears successful, it says 1 rows copied but when I double click on the file created it says "cannot open this file". If I modify the statement to select different rows and copy them to a text file using something like:

bcp "SELECT Name,Address FROM BigTable WHERE RecordId='ASDF-QWER' queryout "C:\Path\File.txt" -n -SCONNECTION\STRING -T

Then the text file contains the data I expect it to contain

schnimmy
  • 43
  • 3
  • 9
  • Possible duplicate of [SQL Server BCP export corrupted file?](http://stackoverflow.com/questions/27301763/sql-server-bcp-export-corrupted-file) – James Z Mar 11 '17 at 20:31
  • @JamesZ I've looked at that question and its answers, in particular I have tried using a format file, the export works but the file is still unopenable – schnimmy Mar 12 '17 at 08:50
  • You should look into the contents of the file. That could explain what happens. – James Z Mar 12 '17 at 08:52
  • Duplicate: http://stackoverflow.com/questions/7597321/export-image-column-from-sql-server-2000-using-bcp – Jasper Schellingerhout Mar 14 '17 at 22:49

0 Answers0