Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 updte multiple values in single column

Author  Topic 

learning_grsql
Posting Yak Master

230 Posts

Posted - 2012-08-28 : 08:38:17
Hi,

I want to update multiple values in a column based on condition. I tried the code below but I get error "Subquery returned more than 1 value. This is not permitted when the subquery follows".

update tbltable set organisationname =
(select case when partyname like 'a%' Then 'ABC'
when partycolumn like 'x%' Then 'XYZ' else organisationname end
from tbltable
where date between '20120801' and '20120831')

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2012-08-28 : 08:44:16
UPDATE tbltable
SET organisationname = CASE WHEN partyname LIKE 'a%' THEN 'ABC'
WHEN partycolumn LIKE 'x%' THEN 'XYZ'
ELSE organisationname
END
WHERE date BETWEEN '20120801' AND '20120831'

--------------------------
http://connectsql.blogspot.com/
Go to Top of Page

learning_grsql
Posting Yak Master

230 Posts

Posted - 2012-08-28 : 10:46:32
thanks dude
Go to Top of Page
   

- Advertisement -