• L' Eomot Inversé (4/19/2013)


    There is one issue with the question, albeit an utterly trivial one: it depends on the setting of IMPLICIT_TRANSACTIONS for the connection. If that's set ON, the rollback includes rolling back the two CREATE statements and the select will return not 1 but an error. Of course the default is OFF, but it would be preferable to mention that the OFF setting is assumed.

    Ahh, yes. Good catch, Tom! I should have thought of that when I created the question.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/