事务
begin transacation
declare @sumErrors int=0
//执行sql操作
----------
set @sumErrors=@sumErrors+@@error
----------
set @sumErrors=@sumErrors+@@error
if @sumErrors=0
begion
--表示没出错
commit transacation --提交事务
end
else
begion
rollback
列
begin transaction
declare @sumError int;
set @sumError=0;
select * from ApplyKey
set @sumError=@sumError+@@error
select * from Attachment
set @sumError=@sumError+@@error
if @sumError = 0
begin
print '成功'
commit transaction
end
else
begin
rollback
end
end