存储过程事务 用事务点处理回滚实例

--create table shiwu (asd varchar(20))
--
--select * from shiwu

--创建存储过程
alter procedure qiantaoProc
@asd nchar(50)
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
select error_message()
end catch
end
go
begin transaction outrans
exec qiantaoProc 'gfdgdfsdrfwererwrewrwerewrwerewrwerwerwerwerewrew';
rollback transaction outrans

 

转载于:https://www.cnblogs.com/whpepsi/archive/2013/03/18/2965664.html

你可能感兴趣的:(存储过程事务 用事务点处理回滚实例)