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

  • Fal (10/10/2013)


    dastagiri16 (9/25/2013)


    hi,

    I have a table like

    id city

    1 A

    so i want to update city column from A to B and again B to A by in single statement..please help.

    Thanks

    Dastagiri

    So, update it twice, use single statement. No problem!

    updatemyTable

    setCity =

    case

    when City = A then B

    when City = B then A

    end

    go 2

    According to BOL "GO is not a Transact-SQL statement; it is a command" 😉

    Genius! 😀

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP