标签:line set 回滚事务 int port val import value mic
declare @iErrorCount int set @iErrorCount = 0 begin tran Tran1 insert into t1(Id, c1) values(1,‘1‘) set @iErrorCount=@iErrorCount+@@error insert into t1(Id, c1) values(‘XX2‘,‘2‘) set @iErrorCount=@iErrorCount+@@error if @iErrorCount=0 begin COMMIT TRAN Tran1 --执行事务 end else begin ROLLBACK TRAN Tran1 --回滚事务 end
declare @iErrorCount int set @iErrorCount = 0begin tran Tran1 insert into t1(Id, c1) values(1,‘1‘) set @iErrorCount=@iErrorCount+@@error insert into t1(Id, c1) values(‘XX2‘,‘2‘) set @iErrorCount=@iErrorCount+@@errorif @iErrorCount=0 begin COMMIT TRAN Tran1 --执行事务end else begin ROLLBACK TRAN Tran1 --回滚事务end标签:line set 回滚事务 int port val import value mic
原文地址:http://www.cnblogs.com/mrzhoushare/p/7649767.html