Insert image file in an IMAGE column

  • Hi there,

    How to use an INSERT statement to insert an image file in an IMAGE data type column?

    Thanks,

    AC

  • It's the same as any other insert. You need to text (binary representation) of the image.

    If you have a VB.NET/C# client, you're stream in the image data to the parameter and then pass it in. Nothing special about it.

  • ArthurC (9/25/2007)


    Hi there,

    How to use an INSERT statement to insert an image file in an IMAGE data type column?

    Thanks,

    AC

    If you want to use SQL, have a look at the thread:

    http://www.sqlservercentral.com/Forums/Topic378279-338-1.aspx

    Regards,

    Andras

    ps: sorry, the first time my < witht he url was eaten by the new forum software.


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • I checked in the MSDN web site again but still don't have a clue. I believe I must use TEXTPTR function somehow! It would be helpful if anyone of you provide an example of the INSERT statement. I want to use INSERT statement to insert records with image for an IMAGE data type column in a table.

    Many thanks,

    AC

  • Thanks for the thread. May be my message was not clear enough. I am looking for a pure database SQL INSERT statement to insert records with image file such as jpg, bmp etc. Any idea!?

    Thanks,

    AC

  • this will work for any binary file it was here on SCC from 07*02/2007 post if you want to google the whole thread.

    INSERT INTO myTable(Document) SELECT * FROM OPENROWSET(BULK N'C:\Image1.jpg', SINGLE_BLOB) AS Document

    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 for your solution Lowell.

  • How do you then save a VarBinary(MAX) image as a valid graphic file?

    Best wishes,
    Phil Factor

  • to insert image form application go through the following steps

    1. create a stream to read file

    2. convert all the data in binary format

    3. create parameters to pass to image and (other value)

    4. execute the sql insert command / procedure

    Note:- Parameter should be image type when you pass byte info

Viewing 10 posts - 1 through 9 (of 9 total)

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