SQL Server query dry run

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!


Begin the transaction, perform the table operations, and rollback as shown below:

BEGIN TRAN

UPDATE  C
SET column1 = 'XXX'
FROM table1 C

SELECT *
FROM table1
WHERE column1 = 'XXX'

ROLLBACK TRAN

This will rollback all the operations performed since the last commit since the beginning of this transaction.

Tags:

Sql

Sql Server