Table image to disk file

  • I need your help.

    If I have a table X that has columns A bigint and B image; how can I extract to a data file with the names being the value of A and content being the data in the image B.

    In other words, I want to get the blob data to a disk file.

    Thanks in advance.

    Phil

     

  • This was removed by the editor as SPAM

  • That is a front end task and can be accomplished in may, many, many, ... did I said many? ...  ways

    To give you a stratrting point just check This article and replace the  the file name of the destination path for the contents of the A column!! 

     HTH


    * Noel

  • I agree with noeld that there are definitely a lot of ways to do this.  From a T-SQL point of view, I found the following useful link, which creates user functions in SQL Server to write the BLOB contents to a file.  Using these functions and stored procedures, you can create a cursor to step through each row in the table and create the necessary image files:

    First download NTEXTCODE.exe from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsqlpro03/html/sp03g8.asp

    After compiling the procedures and functions use a cursor:

    DECLARE @filename VARCHAR(255)

    DECLARE @where VARCHAR(400)

    declare image_crs cursor for

     select <PathColumn> FROM <ImageTable>

    open image_crs

    fetch image_crs into @filename

    while @@fetch_status >= 0

    begin

     SET @where = 'where <PathColumn>=''' + @filename + ''''

     exec master..saveImage2file @filename, '<DB>..<ImageTable>', '<ImageColumn>', @where

     fetch image_crs into @filename

    end

    deallocate image_crs

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

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