how to save a blob to harddisk?

  • Hello,

    I am trying to extract BLOB images from a table and storing each one to a file. I have used the code below to extract the images okay, but when i try to open or preview the images, i get a message saying they are in the wrong format. Any ideas would be greatly appreciated...

    SET @zSQL = 'bcp "SELECT zData FROM database.dbo.table WHERE lID ='+CAST(@lID AS VARCHAR(255))+'" queryout "C:\temp\'+@zFile+'" -T -N -SServer'

    EXEC master..xp_cmdshell @zSQL

    Thanks,

    Andy

  • can you tell your query to save to a file instead of a grid/text and just select what you need? may wanna turn off the (rows affected) stuff

  • Getting the data to a file is always a client side operation. Saving results to a file might work if you return the blog only. Might need to muck with the headers a bit.

  • Heh... Ice Cream Scoop... :hehe:

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 16 through 18 (of 18 total)

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