标签:
--创建存储过程
create procedure qiantaoProc
@asd nchar(10)
as
begin
begin try
begin transaction innerTrans
save transaction savepoint --创建事务保存点
insert into shiwu (asd) values (@asd);
commit transaction innerTrans
end try
begin catch
rollback transaction savepoint --回滚到保存点
commit transaction innerTrans
end catch
end
go
begin transaction outrans
exec qiantaoProc ‘asdasd‘;
rollback transaction outrans
事务嵌套,回滚外层事务时,如果嵌套内的事务已经回滚过则会有异常。此时需要使用事务保存点。
标签:
原文地址:http://www.cnblogs.com/oufeng/p/5741838.html