Retrieving BLOB file from DB and save into disk using BCP?

  • how to retrieve a single document file (stored as BLOB) and save it into disk by using BCP command.

    I've tried bcp "query" queryout "filepath&name" ...

    But still not able to work. No error msg prompt, but no file save into the path I've specified.

    Please help! Thanks.

  • Difficult to say without seeing real query used

  • SSC poster Elliot Whitlow has this CLR project for file manipulation , and includes Blob read write stuff as well;

    it took me about three minutes to install, and has worked very well for me so far;

    http://nclsqlclrfile.codeplex.com/

    it's a lot easier to use than bcp.

    I have an example of importing a blob from disk to table, but not from db to disk; i've always done it in a programming language instead.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks, I'll try.

  • Tan Hui Siang (10/2/2011)


    Thanks, I'll try.

    Elliot's Project makes the image insertion really simple;

    here's a code example...once you have the CLR in place, it is soooo simple:

    CREATE TABLE myImages(id int,filename varchar(200),rawimage varbinary(max) )

    INSERT INTO myImages(id,filename,rawimage)

    SELECT 1,'fedora_spinner.gif',dbo.MFGetFileImage('C:\Data\','fedora_spinner.gif' )

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply