• Good question, and an excellent explanation apart from the point raised by Christian. I don't think the comments are misleading, it is pretty common for a comment to be used simply to label a piece of code (as here) and also pretty common for a comment to say what a piece of code will do if it is executed but not say whether it will be executed or not.

    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. I'll admit that I would almost certainly have forgotten to mention that myself if I had produced this question, though, and I don't consider leaving it out an omission that in any way spoils the question.

    Tom