Explicitly declare a Database Transaction

Source: Internet
Author: User

When SET XACT_ABORT is ON, if a running error occurs when a Transact-SQL statement is executed, the entire transaction is terminated and rolled back.

When SET XACT_ABORT is OFF, only the wrong Transact-SQL statement is generated and the transaction will continue to be processed. If the error is serious, the entire transaction may be rolled back even if SET XACT_ABORT is OFF.

Compilation errors (such as syntax errors) are not affected by SET XACT_ABORT.

For most ole db providers (including SQL Server), XACT_ABORT In the implicit or display transaction data modification statement must be set to ON. The only case where this option is not required is when the Provider supports nested transactions. For more information, see distributed queries and distributed transactions.

SET XACT_ABORT is SET during execution or running, rather than during analysis.

 

 

Set xact_abort on

Begin tran

....

SQL statement

...

Commit tran

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.