SQL Server cannot undo DROP TABLE because the table is removed from the database immediately. Three methods bring back a deleted table. Restoring a backup copy and querying a database snapshot are free but need a copy made before the drop. Software scans the MDF file and flags deleted tables in red when no copy exists. Copies made with SELECT INTO contain rows only so indexes and constraints need a rebuild. Practice on a copy before the live database.
Someone drops the Invoices table during a cleanup and the billing screen shows an error. Backups are old and nobody remembers creating a snapshot.
Search results for this problem push the log decoding method or the software scan. Few explain how to move the table back with its keys and indexes.
This guide explains how to get a deleted table and its data back with the least risk, including the snapshot method that needs one T-SQL statement.
Per the Microsoft SELECT INTO clause reference SELECT INTO creates a new table and does not transfer indexes or constraints or triggers.
What Happens to a Table After DROP TABLE?
Dropping a table removes its structure and its rows from the database. Confirm the loss with a catalog query before you start.
SELECT name, create_date
FROM sys.tables
WHERE name = N'Invoices';
No row means the table is gone. Find the drop time with the trace query in the deleted objects guide and choose the source from the table below.
| Situation | Source | Method |
|---|---|---|
| Backup exists | Restored copy of the backup | #1 |
| Snapshot made before the drop | Database snapshot | #2 |
| No backup and no snapshot | MDF file | #3 |
3 Methods to Recover a Deleted Table in SQL Server
Two free methods need a copy made before the drop while Method #3 needs only the MDF file.
| Feature | Restored Backup | Database Snapshot | Recovery Software |
|---|---|---|---|
| Cost | No cost | No cost | Free scan and paid export |
| Best for | Tables in a recent full backup | Teams that snapshot before releases | Databases with no copy |
| Needs | Full backup and disk space | Snapshot created before the drop | Windows machine and the MDF file copy |
| Main limit | Rows added later are gone | Snapshot must predate the drop | Trial export limit |
Method #1: Copy the Table From a Restored Backup (Free, Needs a Backup)
Restore the latest full backup as StudioDB_Copy to reach the deleted table. Your live database remains unchanged. Steps for the dialog sit in the Microsoft restore a database backup using SSMS guide.
Copy the table across with SELECT INTO. Microsoft states that the statement can use a three part name for another database on the same instance.
BEGIN TRANSACTION;
SELECT *
INTO StudioDB.dbo.Invoices
FROM StudioDB_Copy.dbo.Invoices;
COMMIT TRANSACTION;
Microsoft states that SELECT INTO is not atomic by default and the empty table remains when the inserts fail. Wrapping the copy in an explicit transaction gives all or nothing behavior. You need CREATE TABLE permission in the database and ALTER permission on the schema.
Microsoft warns that Take tail-log backup before restore puts the live database in the restoring state when it remains ticked. Untick it on the Options page.
Method #2: Copy the Table Back From a Database Snapshot (Free, Needs a Snapshot)
Microsoft describes a database snapshot as a static and transactionally consistent view of the source database at creation time. Microsoft names copy back as a way to recover a dropped table. Snapshots must exist before the drop and must live on the same instance.
Query the snapshot like a database and copy the deleted table.
SELECT *
INTO StudioDB.dbo.Invoices
FROM StudioDB_Snap.dbo.Invoices;
Create the snapshot before every release so the next drop costs nothing. Microsoft requires an entry for every data file and accepts no log file in the snapshot creation statement.
CREATE DATABASE StudioDB_Snap
ON (NAME = StudioDB, FILENAME = N'E:\SQLData\StudioDB_Snap.ss')
AS SNAPSHOT OF StudioDB;
Microsoft states that SSMS cannot create snapshots so T-SQL is the only method. Snapshots are no backup substitute and they prevent a drop or restore of the source database while they exist.
Method #3: Recover the Table Without a Backup Using EmailDoctor (Free Preview, Paid Export)
Without copies you work from the MDF file. EmailDoctor SQL Database Recovery lists the deleted tables in red under Tables and exports them with their rows into a new database.
Copy the MDF file to a separate folder before the scan. Per vendor notes a trial export stops at 25 rows of a single table plus 5 further objects.
Find the Deleted Table in the MDF File
- Double click the recovery software shortcut.
- Select Open and add the StudioDB.mdf copy.
- Mark Advance Scan and Recover Deleted Objects in the scan window. Add Auto detect too.
- Check the scan report when the scan ends.
- Open Tables in the tree and find the deleted table. Its name shows in red. Click it to see the rows.
Export the Table to a New Database
- Click Export and select the SQL Server Database option.
- Choose your SQL Server name and sign in.
- Select Create New Database and type StudioDB_Recovered as the name.
- Tick the deleted table under TABLES in the export tree.
- Under Export choose With Schema & Data, tick Export Deleted Objects and press Export.
- Confirm the Export Completed message.
- Open SSMS and expand Databases. Copy the table into the live database with the SELECT INTO query from Method #1.
How to Rebuild Indexes and Constraints After the Copy?
SELECT INTO moves columns and rows only. Script the structure of the deleted table from the restored copy or the snapshot. Right click the table and select Script Table as and CREATE To.
ALTER TABLE dbo.Invoices
ADD CONSTRAINT PK_Invoices PRIMARY KEY (invoice_id);
CREATE INDEX IX_Invoices_Customer
ON dbo.Invoices (customer_id);
Microsoft states that an identity column retains its property in a plain SELECT INTO but loses it when the query joins tables. Check the columns after the copy.
Which Problems Stop a Table Recovery?
Five problems stop most recoveries of a deleted table:
| Problem | Reason | Fix |
|---|---|---|
| SELECT INTO reports an existing object | The table name is in use in the live database | Rename the old table or use INSERT INTO with SELECT |
| Copied table has no primary key | SELECT INTO omits indexes and constraints | Script and create them after the copy |
| Snapshot creation fails | The statement lists a log file or omits a data file | List every data file and no log file |
| No snapshot exists | It must be created before the drop | Use Method #1 or Method #3 |
| Source database cannot be restored | A snapshot of it still exists | Drop the snapshot first |
Method #3 is the last resort here. Work on a duplicate of the MDF file.
Frequently Asked Questions
Is a Backup Required to Recover a Deleted Table?
No. Scanning the MDF file flags deleted tables in red. Export the table with its rows to a new database.
Does SELECT INTO Copy Indexes?
No. Microsoft states that indexes and constraints and triggers are not transferred. Create them after the copy.
Can a Database Snapshot Recover a Dropped Table?
Yes. Microsoft names copy back from the snapshot as a way to recover a dropped table. Snapshots must exist before the drop.
Can I Create a Snapshot After the Drop?
No. Snapshots show the database as of their creation time so a table dropped earlier remains invisible.
Does SSMS Create Snapshots?
No. Microsoft states that T-SQL is the only method for creating a database snapshot.
Is a Snapshot a Backup?
No. Microsoft states that a snapshot is not a backup substitute and gives no protection from disk errors or corruption.
Which Permissions Does SELECT INTO Need?
Microsoft lists CREATE TABLE permission in the database and ALTER permission on the schema.
Can I Restore One Table From a BAK File?
Yes. Restore the backup with a different database name and copy just the deleted table. Your live database remains untouched.
Does Recovery Software Export the Rows of a Table?
Yes. Choose With Schema & Data in the export window and the new database receives the table and its rows.
Does the Trial Export Have a Limit?
Yes. Vendor notes put a trial export at 25 rows for a single table plus 5 further objects. Licensing removes the restriction.
Author’s Verdict
DROP TABLE has no undo. Check sys.tables first and then use the copy you have.
Restore a backup copy for a recently deleted table and use a snapshot when one exists. Recovery software saves the table when nothing else does.
Rebuild keys and indexes after every SELECT INTO copy. Create a snapshot before the next release.
- DROP TABLE removes the table immediately without any undo.
- Restored backups and database snapshots both return a deleted table through SELECT INTO.
- SELECT INTO omits indexes and constraints and triggers.
- Snapshots must exist before the drop and T-SQL is the only way to create one.
- Recovery software exports deleted tables with their rows from an MDF scan.
- Try the scripts on a test copy before production use.