A bit OT: TransactionScope and @@trancount

A bit OT: TransactionScope and @@trancount

Old forum URL: forums.lhotka.net/forums/t/5076.aspx


ajj3085 posted on Wednesday, July 09, 2008

HI,

I was wondering if anyone noticed this.  I have an SP that will start a transaction if @@trancount is 0, and commit or rollback based on if the update failed. 

I'm calling this procedure in a dataportal method that has the TS attribute, but the sp still has it's @@trancount at zero.  I thought this was odd..  anyone have any explanation?

Thanks
Andy

detritus replied on Sunday, September 07, 2008

Just as a note, assuming you're talking with Microsoft SQL Server, your SP should commit the transaction only if it's the owner of it (and the action is successful of course). SQL Server complains if the @@trancount is different before and after the call to the SP.

Sinan

Copyright (c) Marimer LLC