Home » Blog » SQL Server » How to Recover Deleted Table in SQL Server

How to Recover Deleted Table in SQL Server

Neeraj Kumar
Published By Neeraj Kumar
Debasish Pramanik
Approved By Debasish Pramanik
Published On
Last Updated

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.

SituationSourceMethod
Backup existsRestored copy of the backup#1
Snapshot made before the dropDatabase snapshot#2
No backup and no snapshotMDF 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.

FeatureRestored BackupDatabase SnapshotRecovery Software
CostNo costNo costFree scan and paid export
Best forTables in a recent full backupTeams that snapshot before releasesDatabases with no copy
NeedsFull backup and disk spaceSnapshot created before the dropWindows machine and the MDF file copy
Main limitRows added later are goneSnapshot must predate the dropTrial 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

  1. Double click the recovery software shortcut. Recovery software home screen
  2. Select Open and add the StudioDB.mdf copy. Open button Select MDF file window
  3. Mark Advance Scan and Recover Deleted Objects in the scan window. Add Auto detect too. Advance Scan option
  4. Check the scan report when the scan ends. Scan report
  5. Open Tables in the tree and find the deleted table. Its name shows in red. Click it to see the rows. Deleted objects in red

Export the Table to a New Database

  1. Click Export and select the SQL Server Database option. Export button Export options
  2. Choose your SQL Server name and sign in. SQL Server name list
  3. Select Create New Database and type StudioDB_Recovered as the name. Create New Database option Database name box
  4. Tick the deleted table under TABLES in the export tree. Database components list
  5. Under Export choose With Schema & Data, tick Export Deleted Objects and press Export. Export deleted objects option
  6. Confirm the Export Completed message. Export Completed window
  7. Open SSMS and expand Databases. Copy the table into the live database with the SELECT INTO query from Method #1. Recovered database in SQL Server

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:

ProblemReasonFix
SELECT INTO reports an existing objectThe table name is in use in the live databaseRename the old table or use INSERT INTO with SELECT
Copied table has no primary keySELECT INTO omits indexes and constraintsScript and create them after the copy
Snapshot creation failsThe statement lists a log file or omits a data fileList every data file and no log file
No snapshot existsIt must be created before the dropUse Method #1 or Method #3
Source database cannot be restoredA snapshot of it still existsDrop 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.
  Neeraj Kumar

By Neeraj Kumar

Neeraj Kumar is a Principal Technical Architect at EmailDoctor with 19+ years of experience in email migration, cloud migration, data recovery and digital forensics. He guides enterprise teams through Exchange, Office 365 and Google Workspace projects and shares what works as an EmailDoctor writer. Every method in his posts is tested on Windows and Mac before it goes live.