Home Forums SQL Server 2012 SQL Server 2012 - T-SQL how to update column city value from 'A' to 'B' and 'B' to 'A' in single query RE: how to update column city value from 'A' to 'B' and 'B' to 'A' in single query
nitinkachhwaha
SSC Enthusiast
Points: 114
More actions
October 10, 2013 at 4:15 am
#1657432
Hi,
Please find the query to update the cty to 'A' where cty is 'B' and from cty 'B' to 'A'.
BEGIN TRAN
SELECT *FROM CITY
UPDATE CITY
SET CTY = CASE WHEN CTY = 'A' THEN 'B'
WHEN CTY ='B' THEN 'A'
END
ROLLBACK