SQL回滚Transaction来调试SQL语句
用事务回滚来调试SQL,可以避免错误操作对数据库的影响.MARK.
Code
BEGIN TRANSACTION
SAVE TRANSACTION StartOrder;
-- here insert or delete data
--IF @@ERROR <> 0 ROLLBACK TRANSACTION StartOrder;
IF 1 <> 0 ROLLBACK TRANSACTION StartOrder;
COMMIT TRANSACTION
BEGIN TRANSACTION
SAVE TRANSACTION StartOrder;
-- here insert or delete data
--IF @@ERROR <> 0 ROLLBACK TRANSACTION StartOrder;
IF 1 <> 0 ROLLBACK TRANSACTION StartOrder;
COMMIT TRANSACTION
简单点
Code
begin tran
-- here insert or delete data
rollback tran
begin tran
-- here insert or delete data
rollback tran