SQLServer事务回滚添加

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
posted @ 2012-08-27 07:32  TiestoRay  阅读(236)  评论(0编辑  收藏  举报