SQL Server query dry run

后端 未结 2 542
遥遥无期
遥遥无期 2021-02-01 15:52

I run a lot of queries that perform INSERT\'s, insert SELECT\'s, UPDATE\'s and ALTER\'s on tables, and when developing these

2条回答
  •  遇见更好的自我
    2021-02-01 16:11

    Use an SQL transaction to make your changes then back them out.

    Before you execute your script:

    BEGIN TRANSACTION;
    

    After you execute your script and have done your checking:

    ROLLBACK TRANSACTION;
    

    Every change in your script will then be undone.

    Note: Make sure you don't have a COMMIT in your script!

提交回复
热议问题