Key Points of SQL server try catch and transaction

Source: Internet
Author: User

Msdn provides a good explanation of transaction and error handling.

If you have any questions, you can check that.

Here we will extract some important words.

"
If an error prevents the successful completion of a transaction, SQL Server automatically rolls back the transaction and frees all resources held by the transaction.

 

If a run-time statement error (such as a constraint violation) occurs in a batch, the default behavior in the Database Engine is to roll back only the statement that generated the error.

 

It is important to keep transactions as short as possible. when a transaction is started, a database management system (DBMS) must hold your resources until the end of the transaction to protect the atomicity, consistency, isolation, and durability (ACID) properties of the transaction.

 

A try... CATCH construct catches all execution errors that have a severity higher than 10 that do not close the database connection.

 

Errors trapped by a CATCH block are not returned to the calling application ."

(If you want to return an error to the program or client, use RAISERROR)

 

 

Related Article

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.