日期:2014-05-18 浏览次数:20666 次
begin tran delete from temp_001 where id>37000 insert into temp_001 select null,0,0,0,0,0,0,0,0,0,0,0 delete from temp_002 where id>37000 if @@error<>0 --判断如果三条语句有任何一条出现错误 begin rollback tran --–开始执行事务的回滚, end else --如何三条都执行成功 begin commit tran --执行这个事务的操作 end
begin tran delete from temp_001 where id>37000 insert into temp_001 select null,0,0,0,0,0,0,0,0,0,0,0 delete from temp_002 where id>37000 commit tran --执行这个事务的操作 if @@error<>0 --判断如果三条语句有任何一条出现错误 rollback tran --–开始执行事务的回滚,
------解决方案--------------------
begin try begin tran delete from temp_001 where id>37000 insert into temp_001 select null,0,0,0,0,0,0,0,0,0,0,0 delete from temp_002 where id>37000 commit tran end try begin catch rollback tran end catch
------解决方案--------------------
set xact_abort on begin tran delete from temp_001 where id>37000 insert into temp_001 select null,0,0,0,0,0,0,0,0,0,0,0 delete from temp_002 where id>37000 commit tran