How can we Update Image in SqlServer Ce???

  • sivak42

    SSC Veteran

    Points: 243

    Hi guys,

    I would lilke know.I have a column called Image in the database. The type of of the column is Image. I want to upade it. I have an jpg file. How can do that????

    Lets say I can retrieve an image file from url,

    then save it into the sql server ce.....

    not insert ...i want to update...

    Thank you

  • SwePeso

    SSC-Dedicated

    Points: 39693

    Try this

    UPDATE t

    SET t.Img = s.Img

    FROM MyTable AS t

    INNER JOIN OPENROWSET(BULK N'C:\Image1.jpg', SINGLE_BLOB) AS s(Img)


    N 56°04'39.16"
    E 12°55'05.25"

  • max 23838

    SSC Journeyman

    Points: 84

    Another syntax worked better for me. I had added a Picture column to a table ([font="Courier New"]Model[/font]), and wanted to update existing rows in the table with images from files - in this case [font="Courier New"]Picture.jpg[/font]. The kicker was realising that you needed 2 aliases (PictureTable and blob).

    WITH PictureTable AS (SELECT blob.* FROM OPENROWSET(BULK N'C:\Picture.jpg', SINGLE_BLOB) AS blob)

    UPDATE Model

    SET Model.Picture = PictureTable.BulkColumn

    FROM Model, PictureTable

    WHERE Model.Id = 2;

  • max 23838

    SSC Journeyman

    Points: 84

    ...or even more succinctly:

    UPDATE Model

    SET [Picture] = (SELECT MyImage.* from Openrowset(Bulk 'C:\cartridge1.jpg', Single_Blob) MyImage)

    WHERE Id = 9

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

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