Difference between Implicit and Explicit Transaction

后端 未结 4 1928
长情又很酷
长情又很酷 2020-12-09 10:06

What is the difference between Implicit and Explicit transaction in Sql Server 2008?

What happens in TransactionScope background? I\'m using TransactionScope but in

4条回答
  •  心在旅途
    2020-12-09 10:33

    • Implicit Transactions: http://msdn.microsoft.com/en-us/library/ms188317.aspx
    • SET IMPLICIT_TRANSACTIONS { ON | OFF} http://msdn.microsoft.com/en-us/library/ms187807.aspx

    Basically, in c# when you set the TransactionScope to Implicit, it calls the SQL Server SET command to put the connection in IMPLICIT_TRANSACTIONS mode. Anything that you do (using one of the commands listed in the 2nd link) starts a transaction that is kept open until a commit is issued. If no commit is issued at the end of a connection, an implicit ROLLBACK is performed.

    This differs from the OFF setting, which also puts every statement into a transaction - the difference is that in the OFF mode (therefore transactions are explicit), each transaction (singular statement) is immediately committed.

提交回复
热议问题