Query to retreive image from db

  • Hi,

    Please provide me the query to insert image at specific row i.e.

    INSERT INTO Tablename -> Cloumnname -> where id ="xx"

  • fwiw you insert an image column just like any other column.

    insert into yourtable (yourimagecolumnname) values (@thevariable)

    BOL will help you !

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Can you script out the table definition and show it to us?

    Thanks,

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Below is the query which i know to insert an image but i dont know how can i modify this query and insert at specific row.i.e. with WHERE clause.

    In my table i have imgID,imgType,imgData,imgTitle,imgLength as column name.

    INSERT INTO tblImage(imgData)

    SELECT * FROM

    OPENROWSET(BULK N'F:\MUKESH PERS\Images\200810A0\Image026.jpg', SINGLE_BLOB)

    AS imgData

    GO

  • makjain (11/29/2008)


    Below is the query which i know to insert an image but i dont know how can i modify this query and insert at specific row.i.e. with WHERE clause.

    In my table i have imgID,imgType,imgData,imgTitle,imgLength as column name.

    INSERT INTO tblImage(imgData)

    SELECT * FROM

    OPENROWSET(BULK N'F:\MUKESH PERS\Images\200810A0\Image026.jpg', SINGLE_BLOB)

    AS imgData

    GO

    Did you mean to actually UPDATE a row where ImgID = x? If NOT, and you have to insert imgID manually, then couldn't you do something like:

    INSERT INTO tblImage(imgID, imgData)

    SELECT 5 AS imgID, imgData.*

    FROM OPENROWSET(BULK N'F:\MUKESH PERS\Images\200810A0\Image026.jpg', SINGLE_BLOB) AS imgData

    [font="Tahoma"]Zycon - The Search Engine for Manufacturers[/url]. Helping Engineers and Technical Buyers Locate Aluminum Extrusions, Metal Stampers, Plastic Fabricators, Valves, and More.[/font]

  • Yes, i want to update a row with image data where imgid = X.

    Please reply m waiting eagerly

  • Try something like this (untested):

    UPDATE tblImage

    SET imgData = (SELECT BulkColumn FROM

    OPENROWSET(BULK N'F:\MUKESH PERS\Images\200810A0\Image026.jpg', SINGLE_BLOB))

    WHERE (imgID = 5)

    Of course, replace the imgID = 5 with the correct ID.

    [font="Tahoma"]Zycon - The Search Engine for Manufacturers[/url]. Helping Engineers and Technical Buyers Locate Aluminum Extrusions, Metal Stampers, Plastic Fabricators, Valves, and More.[/font]

  • Hi Friend,

    I m getting below underlined error message when i tried to update the table.

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

  • makjain (12/2/2008)


    Hi Friend,

    I m getting below underlined error message when i tried to update the table.

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

    Try this one then:

    UPDATE tblImage

    SET imgData = (SELECT BulkColumn FROM

    OPENROWSET(BULK 'F:\MUKESH PERS\Images\200810A0\Image026.jpg', SINGLE_BLOB) AS i)

    WHERE (imgID = X)

    Note the "AS i" portion.

    [font="Tahoma"]Zycon - The Search Engine for Manufacturers[/url]. Helping Engineers and Technical Buyers Locate Aluminum Extrusions, Metal Stampers, Plastic Fabricators, Valves, and More.[/font]

  • OK gr8.....now its working

    Lots of blessing and thanx.....Finally

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

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