DECLARE @iErrorCount INT SET @iErrorCount = 0 SET XACT_ABORT ON BEGIN TRAN Tran_Custom
INSERT/UPDATE/DELETE .... SET @iErrorCount=@iErrorCount+@@error --加到增删改操作的后面 IF @iErrorCount=0 BEGIN COMMIT TRAN Tran_Custom END ELSE BEGIN ROLLBACK TRAN Tran_Custom END