An accidentally dropped table may be recovered in several ways. The choice of technique depends on the resources available for the recovery. The first choice is usually a database backup. But, even if the one doesn’t exist, the dropped table may still be recovered (in some cases even quicker than with a backup).
Let’s see how this can be done:
If there is a full database backup or a chain of differential backups containing the dropped table:
Restore the database on a test server
CREATE TABLE [dbo].[Orders]( [Id] [int] NOT NULL, [OrderNo] [int] NOT NULL, [CustomerId] [int] NULL, [OrderDate] [date] NULL ) ON [PRIMARY] GO INSERT [dbo].[Orders] ([Id], [OrderNo], [CustomerId], [OrderDate]) VALUES (1, 1000, 35, CAST(0x2A370B00 AS Date)) ALTER TABLE [dbo].[Orders] ADD DEFAULT (getdate()) FOR [OrderDate] GO
This method is simple and straightforward, the only setback being that it is not applicable if there’s no database backup. Also, if the database is large, backup restoration can be time-consuming.
This is another method where a database backup is necessary, but it doesn’t have to be restored to recover lost tables due to Drop table operation.
ApexSQL Diff is a SQL server comparison and synchronization tool for SQL Server databases. It detects differences between database objects, generates comprehensive reports and synchronizes databases, database backups, snapshots, script folders and source control projects.
In order to recover lost table with ApexSQL Diff, follow these steps:
Start ApexSQL Diff
Expand the Advanced options and four additional tabs will be shown
|
Quick tip: To have all objects that depend on the dropped table correctly scripted – triggers, tables, etc., leave all object types selected |
Click the Compare button in the bottom-right corner of the New project window
To script the objects the dropped table depends on, select them from the dependent objects list
Go through the first two steps of the Synchronization wizard
Click the Next button and review the Summary and any potential Warnings in the last step of the Synchronization wizard
If everything is in order, click the Create script button
The table and the dependent objects selected will be re-created.
As ApexSQL Diff can read SQL Server database backups, the table recovery is faster as the backups are not being restored first. The objects depending on the dropped table are seamlessly recovered. The main grid shows the script and differences for every object, which provides granularity and helps in deciding which objects to select for synchronization.
If a SQL database backup doesn’t exist, this method is not applicable. Also, only the table structure can be recovered.
Note: ApexSQL Diff will only recover structure of the dropped table (and the dependent objects). In order to recover data, ApexSQL Data Diff needs to be used in the similar way to compare and synchronize data and it can be read from article Recover deleted SQL data from a backup or from online database files.
Even if there’s no SQL database backup containing the dropped table, recover of lost tables due to Drop table operation can be done.
ApexSQL Log is a SQL server transaction log viewer that audits, reverts or replays data and object changes. It restores deleted and modified data and objects, capturing information on the user, application and host used to make each change.
In order to recover lost table with ApexSQL Log, follow these steps:
Start ApexSQL Log
Please note that the transaction logs have to form a full chain.
Once the Finish button is clicked, all Drop table operations that exist in the online transaction log and added transaction log backups will be shown in the main grid
The advantages of this method are that no database backup is needed. As the Drop table statement doesn’t create a log for each deleted table row in the online transaction log, this method can recover only table structure.
Note that if the database is in the Simple recovery model, the transactions might be overwritten. In this case, the sooner that ApexSQL Log is run after the table was dropped, there are more chances for successful recovery.
Note: Performing a table recovery with ApexSQL Log will only recover table structure, the data is not recovered.
As ApexSQL Recover reads both data (MDF) and transaction log (LDF) files, it can recover a dropped table even when the transaction doesn’t exist in the LDF file anymore. Furthermore, ApexSQL Recover recovers both structure and data lost due to Drop table operation.
ApexSQL Recover is a SQL Server recovery tool that recovers deleted, dropped or truncated data. It recovers objects and data lost due to drop operations and restores both deleted and online BLOBs as files.
To recover lost table with ApexSQL Recover, follow these steps:
Start ApexSQL Recover
Click the Next button
Thanks to reading both MDF and LDF files, ApexSQL Recover has more chance of successful recovery. However, if the information about the dropped table is overwritten in both MDF and LDF files, ApexSQL Recover cannot help.
Having database backups is a good starting point, but it might not be the quickest one. With backups, there are different methods – the ones that require a backup to be restored first, and thus require more time, and the others that can read backups.
If a database backup doesn’t exist, a dropped table can be recovered from SQL database data and transaction log files. When it comes to recovery from a database in the Simple recovery model, it might fail as the Drop table transaction might have been overwritten. Even then, recovery is possible from the MDF file.
© 2025 Quest Software Inc. ALL RIGHTS RESERVED. 利用規約 プライバシー Cookie Preference Center