How to get and insert length of inserted image?

  • Hi,

    I want to insert length of an image which is already inserted into DB and while inserting new image i want to insert length also so can anyone tell me the query for the same. Below is the query juz to insert an image.

    UPDATE tblImage

    --SET imgData1 = (SELECT BulkColumn FROM

    -- OPENROWSET(BULK 'F:\MUKESH PERS\Images\30122007092.jpg', SINGLE_BLOB) AS i)

    --WHERE (imgID = 3)

  • you can use DATALENGTH to get the size of an existing record, not sure how you would handle a new one. Trigger or Indexed column maybe?



    Shamless self promotion - read my blog http://sirsql.net

  • Get datalength from tbl where productid = 'N340'

    M nt gettin the length i thk m wrong in writing query.

  • select datalength(imagecolumnnamehere) from tbl where productid = 'N340'


    * Noel

  • If you really need a column to show the length, don't store this data and try to keep it updated all the time. Create a computed column or create a view and use the datalength function.

    With a computed column, the column will always be calculated and up to date.

    The same thing applies to a view.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

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

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