BEGIN TRANSACTION
my_transaction_delete
USE
database_name
GO
DELETE FROM table_name WHERE table_column='XXX'
SAVE TRANSACTION after_delete
--设定保存点
UPDATE table_name SET table_column='XXXX' WHERE table_column='XXXXX'
IF @@ERROR!=0
OR @@ROWCOUNT=0 THEN
BEGIN
ROLLBACK TRANSACTION after_delete
/*回滚到保存点after_delete,如果使用
rollback my_transaction_delete
则会回滚到事务前*/
PRINT '更新出错'
END
COMMIT TRANSACTION my_transaction_delete
GO