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

  • If you insist doing it "in single statement", how about this:

    EXEC (...).

    If we'd agree this would qualify as a single statement, we're all set. Right? 😀

    To "support my argument": BOL qualifies EXEC as a statement: ...SQL Server extends the EXECUTE statement...

    Of course, this would be a rather pathetic discussion on thin ice, but at least it could bring you in the position of "it depends" (on the definition of the term "statement" in the given context) instead of "it's not possible" at all 😉

    And, as soon as "statement" is defined more precisely as "DML statement", the "back door" is closed and locked leaving a more detailed question:

    Based on the example provided by dwain a few posts back, if we update a "left" table in a 1 ..n relationship, will sql server perform n updates or will it just do a single update? Will this example really change the value to 'B' and back to 'A'? How would you verify?

    It's a rather weird original question. But with quite some room to open a discussion. Hidden. But available. 😎



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]