[英]Nested SQL Transactions in SQL Server
I have two stored procedures, I call one stored procedure from another stored procedure and in both two stored procedures I use transactions. 我有两个存储过程,我从另一个存储过程调用一个存储过程,在两个存储过程中我使用事务。 Below is the stored procedures,
以下是存储过程,
CREATE PROCEDURE [dbo].[spOuter]
AS
BEGIN
begin tran t1
-- some sql queries..
Exec spInner;
commit tran t1
END
CREATE PROCEDURE [dbo].[spInner]
AS
BEGIN
begin tran t2
– some sql queries.
rollback tran t2
END
but when executing this, It shows error as shown below: 但执行此操作时,它会显示错误,如下所示:
Cannot roll back t2. No transaction or savepoint of that name was found.
Can anybody explain why is it showing? 任何人都能解释为什么会出现这种情况?
Read this articles, you will get some better ideas... 阅读这篇文章,你会得到一些更好的想法......
http://www.codemag.com/article/0305111 http://www.codemag.com/article/0305111
http://technet.microsoft.com/en-us/library/ms189336(v=sql.105).aspx http://technet.microsoft.com/en-us/library/ms189336(v=sql.105).aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.