Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Administration - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 6525

Understanding Implicit_Transaction on - confusing behaviour

$
0
0
Hi all,I do not want autocommit, as i am afraid of making mistakes.So i set implicit_transactions on , but i did encounter the following behavior -Behavior 1 - still able to rollback 1 time after setting implicit transaction off after turning it on.[quote]set implicit_transactions onselect @@options & 2 -- return 2;select * from testtab; -- no rowsinsert into testtab values ('a');select * from testtab; -- return arollback work;select * from testtab; -- no rows[/quote]From the above, we can see that implicit transaction on is working. Autocommit is not longer in work.=================-- testtab still has no rows at the moment.Now i tried to turn implicit_transactions off;[quote]set implicit_transactions offselect @@options & 2; -- return 0insert into testtab values ('a'); select * From testtab; -- return arollback work; [b]-- COMMAND COMPLETED SUCCESSFULLY[/b]select * From testtab; -- return no rows[/quote]q1) Why am i able to still ROLLBACK after setting implication_transactions off ?It is only after the above, then it resume as normal (with autocommit) as shown below[quote]insert into testtab values ('a'); select * From testtab; -- return arollback work; -- now it prompt that the corresponding rollback transaction request has no corresponding BEGIN TRANSACTIONselect * from testtab; -- return a , autocommit is back in place.[/quote]Is what i am experiencing normal ?Regards,Noob

Viewing all articles
Browse latest Browse all 6525

Trending Articles