November 15, 2002 at 11:08 am
I appreciate if anybody can help me to write this UPDATE command. The requirement is to update 3 columns in a table with a subquery accessing same table but different row.
update MY_TAB1
set ( acronym, version)= ( select acronym , version
from MY_TAB1
where Pri_Key=121 )
where Pri_Key=117
This does not work and I do not know how can I update multiple columns at the same time. Thanks.
--Chandra Cheedella
November 15, 2002 at 11:13 am
UPDATE MY_TAB1
SET acronym = (SELECT acronym
FROM MY_TAB1
WHERE Pri_Key = 121),
version = (SELECT version
FROM MY_TAB1
WHERE Pri_Key = 121)
WHERE Pri_key = 117
November 15, 2002 at 12:25 pm
Thanks for your help. This is a round about procedure but I think this is the only to do in SQL Server. In Oracle, it is quite simple.
--Chandra
November 15, 2002 at 2:43 pm
seems pretty easy in SQL Server as well.
Steve Jones
November 15, 2002 at 2:53 pm
Looks pretty straight forward to me too, though I think I would use variables to hold the values and do a single select to get them. Another statement to update them.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply