Updating Image data type with varchar datatype

  • This is what I see in Select statment. It is SQL 2000. What this encryption holds is not necessary as it is used by JD Edward.

    ID Image

    F9801 0x030083FFD5D0803A6650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

    I want to update few rows with Image datatype using T-SQL. Is there any way to writed Update statment and pass this value as varchar. I used below statment but it is not giving desired results at application level.

    UPDATE F980SEC

    Set Imange = '0x050085FFD5D0805A6650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'

    Thanks

    Shahzad

  • Updating Image type data is done via WriteText or UpdateText. It's not simple, but read the documentation and test a few samples and you'll get it.

    Documentation is here: http://msdn.microsoft.com/en-us/library/ms187993.aspx

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • In general, you don't adjust image data from within SQL Server, it's just there to store the binary from another software. Most often you'll pump it out to the correct software, allow it to make the adjustments, and then have it overwrite the old entry.

    For TEXT/VARCHAR(MAX), however, what Gus recommended above is the usual method. However, Text doesn't hold the binary correctly, for things like file headers and the like, because it's expecting it all to be text entries, so you have to decide what the real use of this field is.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • I don't think WriteText/UpdateText work on the (max) datatypes. They do work on Image, but you're right that it's unusual to do so.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • GSquared (12/29/2011)


    I don't think WriteText/UpdateText work on the (max) datatypes. They do work on Image, but you're right that it's unusual to do so.

    True, good catch. They use standard string manipulation functions. So Does VarBinary(MAX) if I remember correctly, but that's about as strange as doing WriteText with Image.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • Evil Kraig F (12/29/2011)


    GSquared (12/29/2011)


    I don't think WriteText/UpdateText work on the (max) datatypes. They do work on Image, but you're right that it's unusual to do so.

    True, good catch. They use standard string manipulation functions. So Does VarBinary(MAX) if I remember correctly, but that's about as strange as doing WriteText with Image.

    Yep.

    Same as any other varchar/nvarchar/varbinary column.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • his is what I see in Select statment. It is SQL 2000. What this encryption holds is not necessary as it is used by JD Edward.

    I don't think WriteText/UpdateText work on the (max) datatypes.

    True, good catch. They use standard string manipulation functions. So Does VarBinary(MAX) if I remember correctly, but that's about as strange as doing WriteText with Image.

    I was unaware of Sql-2000 supporting any MAX data-types

    Director of Transmogrification Services
  • Mad Myche (12/30/2011)


    his is what I see in Select statment. It is SQL 2000. What this encryption holds is not necessary as it is used by JD Edward.

    I don't think WriteText/UpdateText work on the (max) datatypes.

    True, good catch. They use standard string manipulation functions. So Does VarBinary(MAX) if I remember correctly, but that's about as strange as doing WriteText with Image.

    I was unaware of Sql-2000 supporting any MAX data-types

    It doesn't. It has (N)Text and Image instead. That's why I pointed the author of the original question at WriteText and so on.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • You're right, it doesn't, I was just trying to be thorough.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

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

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