9-04 nested transactions and transaction classifications (1)

Source: Internet
Author: User

Global variable @ @TRANCOUNT:

Returns the number of active transactions for the current connection.

An explicit transaction:

Begin TRANSACTION The beginning of a clear real transaction.

The most common type of transaction.

Implicit transactions:

By setting the Setimplicit_transactions on statement,

Sets the stealth transaction mode to open.

The subsequent T-SQL statement automatically starts a new transaction.

Commits or rolls back a transaction, and the next T-SQL statement starts a new transaction.

Commit transactions automatically:

The default mode for SQL Sever.

Each individual T-SQL statement is a transaction.

--commit effect on transaction number (nested transactions used) print  @ @TRANCOUNT--look at the number of transactions without a transaction begin  tran--start transaction     PRINT @@ trancount--start Transaction, @ @TRANCOUNT will be set to 1      begin  tran--start transaction      PRINT  @ @TRANCOUNT--Number of transactions plus 1      COMMIT  tran--Commit Second transaction      print @ @TRANCOUNT--Number of transactions minus 1      commit TRAN--commit first transaction, number of transactions minus 1      PRINT @ @TRANCOUNT     GO

Operation Result:

9-04 nested transactions and transaction classifications (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.