Before running and update or delete queries, make sure you backup your database. But sometimes you don’t want to backup the entire SQL Database. Sometimes you just want to backup a single table, run your query and revert to the previous version.
Here is a simple method to do that.
Step 1: Create an identical copy of the table including data
Run this command in a new query
SELECT * into YourTable_Backup from YourTable
This will create an exact copy of your table and will also copy your data. Now you’ll have 2 tables.
YourTable and YourTable_Backup
Step 2: Revert your table from backup
Run your tests on the YourTable table and once you are done, delete it. Go to the YourTable_Backup and rename it to YourTable.
You are now reverted to the original table.