How to backup a single table in SQL

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.

Run this command in a new query

USE [YourDB]
GO

SELECT * into YourTable_Backup from YourTable
GO

This will create an exact copy of your table and will also copy your data. Now you’ll have 2 tables.

YourTable
YourTable_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.