Reputation: 1733
Want to update specific data in a Table Column.
I can use the below for one entry:
UPDATE [BULDING].[dbo].[TB_DATA]
SET OFFICE_ID = '4' where OFFICE__ID = '8';
But what should I use for multiple entry change - below obviously does not work:
UPDATE [BULDING].[dbo].[TB_DATA]
SET OFFICE_ID = '4' where OFFICE_ID = '8'
SET OFFICE_ID = '4' where OFFICE_ID = '10'
SET OFFICE_ID = '11' where OFFICE__ID = '3';
Thanks!
Upvotes: 1
Views: 126
Reputation: 171391
UPDATE [BULDING].[dbo].[TB_DATA]
SET OFFICE_ID =
case when office_id in ('8', '10') then '4'
when office_id = '3' then '11'
else office_id
end
Upvotes: 6