我在 sql 中有一个循环,它做一些事情
begin tran one
do some inserts in others tables
--start loop
begin tran two
--do something
begin try
--if something fail then a trigger does rollback and this return a error (and this goes to catch), then don't i need do the rollbak in catch? this could not be dissable because this is working on production
--something finished ok
commit tran two
end try
begin catch
rollback tran two
end catch
--finished loop
commit
----------
我收到了这个错误
在批处理结束时检测到不可提交的事务。事务被回滚。
begin tran one
begin tran two
rollback tran two
做这个代码我得到这个:
不能回滚两个。未找到该名称的事务或保存点。
我只希望子查询回滚第二个循环并继续处理其他记录。