• Rich-403221 (10/1/2010)


    I found the question a little misleading due to the fact that you are assigning the trancount to a variable prior to the insert. If you inserted @@trancount DIRECTLY into tranlog, then the answer that showed "(11,1),(2,1),(12,1),(13,1)" would have been the correct answer, as a transaction would have been initiated at the point that the insert statement into the Tranlog table occurred. Other than that minor comment, a great question illustrating transactional behavior in a trigger.

    This construct was to show that @@trancount is zero directly after the rollback statement.

    The insert statement (which is not in the transaction this time) starts the implicit transaction.

    I played with combination of both this inserts, through the variable and @@trancount, but there were to many phenomena for one question.

    I hoped the discussion will cover all these subtle details. And I'm feeling I was right.



    See, understand, learn, try, use efficient
    © Dr.Plch