SQL Server 出错自动回滚

ALTER procedure [dbo].[USP_DELETEMM_SBKP] (@ID INT) as
BEGIN
SET XACT_ABORT ON  --只要出错就回滚 
BEGIN TRAN--开始事务

 ……
 --删除设备图片标签数据
 DELETE A FROM CONFIGURATIONVIEW A WHERE EXISTS(SELECT 1 FROM CONFIGURATIONTREE B WHERE B.ParentNodeID=(@ID*100+1) AND A.NODEID=B.NODEID);

 --删除设备
 DELETE FROM MM_SBKP
 WHERE ID = @ID;

COMMIT TRAN --提交事务

END

你可能感兴趣的:(SQL Server)