How do I use BCP or Sql Server Management Studio to get BLOB data our of Sql Server?

Posted by Eric on Stack Overflow See other posts from Stack Overflow or by Eric
Published on 2010-03-08T21:02:31Z Indexed on 2010/03/08 21:06 UTC
Read the original article Hit count: 234

Filed under:
|
|
|
|

I'm sorry if this question has been asked already, but I couldn't find it anywhere. I have a table that stores files as BLOBS. The column that holds the file is an image datatype. I would like to be able to extract the binary data out of the column and turn it in to an actual file. I would ideally like to be able to do this with BCP or management studio if possible.

I have tried BCP, but for some reason when I try and pull out an office document Word thinks it's corrupt. Here's what I've tried so far (obviously the values have been changed to protect the innocent :):

bcp "select document_binary_data from database where id = 12345" queryout "c:\filename.doc" -n -S server -U username -P password

This isn't working though? Any thoughts?

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about bcp