declare @err int set @err = 0 begin begin transaction tc insert into TWeb_Uff_Box(BoxCode) values('1') set @err = @err + @@error insert into TWeb_Uff_Box(BoxCode) values('2') set @err = @err + @@error insert into TWeb_Uff_Box(BoxCode) values('3') set @err = @err + @@error if(@err > 0) rollback transaction tc else commit transaction tc end