事物
--开始事物BEGIN TRANSACTION --事物回滚ROLLBACK TRANSACTION --事物提交COMMIT TRANSACTION
BEGIN TRANSACTIONdeclare @sumError int=0update bank set balance=balance-1000 where cId='0001'set @sumError=@sumError+@@ERRORupdate bank set balance=balance+1000 where cId='0002'set @sumError=@sumError+@@ERRORif(@sumError<>0)begin --失败了 回滚 --事物回滚 ROLLBACK TRANSACTIONendelsebegin --成功了 --事物提交 COMMIT TRANSACTIONend