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

  • 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

    SELECT *FROM CITY

    ROLLBACK