SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Triggers and Transactions


Triggers and Transactions

Author
Message
honza.mf
honza.mf
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2561 Visits: 1323
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
Tom Thomson
Tom Thomson
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26092 Visits: 12500
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

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search