存储过程事务 用事务点处理回滚实例
--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