Question

Does anyone know of any tools that can help in recovering dropped tables and stored procedures ?

There was no backup taken and this DB was accidentally synced up with another DB and the new tables created in this DB were dropped.

thanks

Was it helpful?

Solution

I googled "sql server restore dropped table" and came up with a helpful forum answer.

http://www.eggheadcafe.com/community/aspnet/13/11519/are-you-sure-you-dont-ha.aspx

"When a database is created in SQL Server, it is set to Full Back Up by default. So, your table should be available by restoring the transaction backup. Try going to the "restore database" options by right clicking on the database name in Enterprise Manager and selecting All Tasks."

I do question if that would restore the table or just the data, though.

There is some fairly low cost software by RedGate called "SQL Log Rescue" that is supposed to help with this. Check out this SQL Server Central article: http://www.sqlservercentral.com/articles/Product+Reviews/sqlrescuereview/2086/

EDIT: The RedGate software does require a full backup, so that won't help. I just caught that.

But perhaps the transaction log will help you in recovering the table structures, even if it can't actually restore the table itself.

OTHER TIPS

If database was in full recovery mode and there are transaction log backups or transaction log was never truncated you might try using a third party log reader such as ApexSQL Log or SQL Log Rescue (free but sql server 2000 only).

Other option for reading transaction log is not so well documented function DBCC LOG.

If full chain of transactions exist this means that previous CREATE or ALTER table that was executed against this table is still in the transaction log somewhere. Unfortunately it’s not an easy task to find this info if your transaction log is very big, especially w/o third party tools.

You can recover the dropped object from SQL Server log as well, If you do not have backup.

Select Convert(varchar(Max),Substring([RowLog Contents 0]
,33
,LEN([RowLog Contents 0]))) as [Script]
from fn_dblog(NULL,NULL)
Where [Operation]='LOP_DELETE_ROWS' And [Context]='LCX_MARK_AS_GHOST'
And [AllocUnitName]='sys.sysobjvalues.clst'

Reference : http://raresql.com/2012/12/04/sql-server-recover-the-dropped-objects-view-stored-procedure-function-trigger/

In which recovery model your db is?

Short answer: Without a backup, you lost your data. That's the whole point of a backup.

Long answer: If recovery model is FULL, and you never took a full backup, it is actually operating as it was in simple recovering model. That means you cant take a transaction log backup, and worse: your transaction log is truncated on every checkpoint. That means even if your dropped table was in the transaction log, it is now almost certainly overwritten by newer transactions and lost forever. No tool can help you there.

If you know the internals of sql db structures, you could do forensics with DBCC PAGE and hope those extents are not yet overwritten with other objects data, but that requires real expert knowledge - you could hire one. You could also check if transaction log records of your table are already overwritten (probably are) with fn_dblog(). There is server-side trace which you could use to identify exact time the table was dropped.

Bottom line: having an automated backup is essential. Only full recovery model enables point-in-time recovery which you could use to recover the table to a point just before drop command.

This worked for me:

Select Convert(varchar(Max), Substring([RowLog Contents 0]
, 33
, LEN([RowLog Contents 0]))) as [Script]
from fn_dblog(NULL, NULL)
Where [Operation] = 'LOP_DELETE_ROWS' And [Context] = 'LCX_MARK_AS_GHOST'
And [AllocUnitName] = 'sys.sysobjvalues.clst'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top