February 15, 2012 at 1:54 am
Hi all,
suppose you submit the following batches one hour apart using the same connection:
Batch 1:
Begin Transaction;
update T1 set ColA=ColA*1.25;
Update T2 Set ColD=ColE*5+ColB;
Batch 2;
Delete T3 where ColF>(select Avg(ColF) from T3)
Insert T4 (Select ColA,ColB,ColC from T1);
Commit Transaction;
what happens when the code in the scenario above is executed? and why?
February 15, 2012 at 2:11 am
The code will do just what it is suppose to do. It will begin the transaction, then will do all the DML statements as part of the transaction (regardless of how much time has passed since the transaction was opened). When it get to the rollback transaction statement, the server will rollback the transaction (again regardless of how much time has passed since it was opened).
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply