Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««1234

Triggers and Transactions Expand / Collapse
Author
Message
Posted Tuesday, October 5, 2010 8:31 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, November 27, 2014 5:23 AM
Points: 1,425, Visits: 1,316
Tom.Thomson (10/5/2010)
Nice question.
But is there something wrong with the documentation? The BoL page referenced states
@@TRANCOUNT is incremented by one when entering a trigger, even when in autocommit mode. (The system treats a trigger as an implied nested transaction.)
which suggests that the two rows logged for the insert of value 2 (which occurred in an explicit transaction) should have tc = 2 not tc = 1.

I don't know. You are right but experiments show this behaviour.
Many times I read BOL or some other documentation I feel like being in the helicopter.




See, understand, learn, try, use efficient
© Dr.Plch
Post #998402
Posted Tuesday, October 5, 2010 12:39 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 7:11 PM
Points: 7,920, Visits: 9,646
honza.mf (10/5/2010)
I don't know. You are right but experiments show this behaviour.
Many times I read BOL or some other documentation I feel like being in the helicopter.

BoL often makes me feel like that. And the experiment in this case shows another oddity: when in autocommit mode, a reference to @@tc in the statement bring auto-committed will be evaluated before the transaction is started (hence the 0 count in the first and fourth rows).

I've written quite a lot of things that look at @@tc for various reasons, but results like these make me very very careful about doing it!


Tom
Post #998673
« Prev Topic | Next Topic »

Add to briefcase «««1234

Permissions Expand / Collapse