Sql Server 中的嵌套事务 [英] Nested transactions in Sql Server

查看:31
本文介绍了Sql Server 中的嵌套事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想象以下场景:

我使用的是 SQL Server 2005.我有一个事务,它在调用其他 SQL 语句中的一个存储过程,该过程内部也有一个事务.外层事务有时会失败,并在调用存储过程并成功提交后回滚.

I am using SQL Server 2005. I have a transaction that is calling, among other SQL statements, a stored procedure that also has a transaction inside. The outer transaction sometimes fails and it is rolled back after the stored procedure is called and committed successfully.

我的问题是,存储过程的事务也会回滚吗?

My question is, does the stored procedure's transaction rollback too?

推荐答案

对于嵌套事务,提交不会将任何更改写入磁盘,除了顶级事务.然而,无论事务的级别如何,回滚都有效,所以是的,它将回滚内部事务.

With a nested transaction, a commit does not write any changes to disk, except for the top level transaction. A rollback, however works regardless of the level of the transaction, so yes, it will roll the inner transaction back.

这篇关于Sql Server 中的嵌套事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆