September 21, 2006 at 4:05 pm
SELECT @@TranCount
SELECT @@TranCount As A INTO #A
SELECT * FROM #A
SELECT @@TranCount
Why I am getting 2 in the table, basically it is inserting 2 in the table inspite there is no transaction.
I know I should assign the value to a variable and then insert .
I am not looking for a solution but an explanation
Amit
Amit Lohia
September 21, 2006 at 5:38 pm
OK disclaimer: I don't know
But based on what I do know about SQL Server...
Each statement is implicitly within a transaction. That is that behind the curtain SQL is issuing a begin tran/commit-rollback around any INS/DEL/UPD/SEL statement.
So that would account for it being 1 greater than the first select @@trancount.
Next I would guess that SQL2k treats the select into as a two step process way down deep: separating the select and the insert, which would account for the 2.
That's my swag at it.
September 25, 2006 at 11:43 pm
I know it's just an experiment but, ugh... if you end up counting transactions in your code, ya just might have a bigger problem with your application...
--Jeff Moden
Change is inevitable... Change for the better is not.
September 26, 2006 at 1:43 am
I guess you're connected using implicit transactions.
(or use an oledb.begintran statement which switches your connection to "implicit transactions)
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply