sql server try catch and transaction的几个要点

msdn 把这transaction 和错误处理讲得很不错。

有什么不清楚可以看看那个。

这里摘抄重要的几句话。

"
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 many 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."

(如果想返回错误给程序或者客户端,使用RAISERROR)

 

 

posted on 2009-03-16 15:09 旴江老段 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/gnaguix/archive/2009/03/16/1413271.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值