【发布时间】:2010-11-19 22:14:31
【问题描述】:
我收到以下错误:
EXECUTE 之后的事务计数表明 BEGIN 和 COMMIT 语句的数量不匹配。先前计数 = 0,当前计数 = 1。
当我尝试执行这个存储过程时:
create procedure [dbo].[SynchCustomerSubscriptions] (
@subscriptions Subscriptions readonly )
as
begin transaction
begin tran SynchTransaction
begin try
delete s
from Subscription s (nolock)
where s.Customer in (
select Customer
from @subscriptions)
exec AddSubscriptions
@subscriptions
end try
begin catch
rollback tran SynchTransaction
return
end catch
commit tran SynchTransaction
有人发现问题了吗?
【问题讨论】:
-
为什么在另一个事务中有一个嵌套事务,并且只提交/回滚一个事务?我的意思是,当你提交时,你提交
SynchTransaction,当你回滚时,你回滚SynchTransaction,但是仍然存在一个事务,即未命名的事务!只是想知道和学习一些东西。 =)
标签: sql sql-server database tsql stored-procedures