to store an Image in Database

  • Guys,

    I have create table with ID and column testimage

    CREATE TABLE IMAGE_TEST

    (

    ID INT IDENTITY (1, 1) NOT NULL,

    TEST_IMAGE IMAGE

    )

    How do I insert an image in this table with DML sql statements is it possible? or does it have to be done using application code

    Thanks

  • INSERT INTO Table (ImageColumn)

    SELECT * FROM OPENROWSET (BULK N'C:\YourPicture.bmp', SINGLE_BLOB)

  • when I run the insert statement I get the following error.

    Msg 491, Level 16, State 1, Line 1

    A correlation name must be specified for the bulk rowset in the from clause.

  • The sample provided was a syntax example. It would not work against your table. Refer to the Books Online (BOL) and adjust to your table name, column name, etc.

    There is a minor correction to the syntax: the OPENROWSET query has to have an alias and be coded as a subquery such as:

    (SELECT * FROM OPENROWSET(BULK N'file name', SINGLE_BLOB) AS x)


    [font="Arial Narrow"](PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.[/font]

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

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