Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    2

    Unhappy Unanswered: Using UPDATE with images

    Hi all,

    I am fairly new at Transact SQL, and am trying to do an update of an image field without success. I was hoping someone could help. My statement is:

    UPDATE [WRKBENCH]
    SET [RSCBYTES]=
    (select [RSCBYTES] from [WRKBENCH] where [CMPID]=101)
    WHERE [CMPID]=102

    I get the following error:

    Server: Msg 279, Level 16, State 3, Line 1
    The text, ntext, and image data types are invalid in this subquery or aggregate expression.

    I've tried using CAST and CONVERT, but without success. Anyone know how to accomplish the above??

    Thanks,

    Martin

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    You cannot use text, image fields in select for subquery.

    create table test (id int, picture image)
    go
    insert test values(1,'qwww')
    insert test values(2,'qwww')
    insert test
    select id+12,picture from test
    go
    update t1 set picture=t2.picture
    from test t1 join test t2 on t1.id=t2.id-- or somethig else

  3. #3
    Join Date
    Oct 2003
    Posts
    2
    Thanks!
    That was the ticket.
    Worked like a charm!!
    M.



    Originally posted by snail
    You cannot use text, image fields in select for subquery.

    create table test (id int, picture image)
    go
    insert test values(1,'qwww')
    insert test values(2,'qwww')
    insert test
    select id+12,picture from test
    go
    update t1 set picture=t2.picture
    from test t1 join test t2 on t1.id=t2.id-- or somethig else

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •