How do I undelete sql server and get records back?

345    Asked by ChrisDyer in SQL Server , Asked on Apr 22, 2021

I mistakenly deleted around 2,000,000 records from a remote SQL Server 2008 table. The server is not granting me access to the backup files on the server side. Is there any way to undelete sql server and get back these records?

Answered by Chloe Burgess

Is your database in full recovery mode?

  • If yes, are you doing transaction log backups?
  • If yes, do you have a backup utility like Quest LiteSpeed, Red Gate SQL Backup, or Idera SQLSafe?
  • If yes, those utilities can undelete objects from backup files (including the fulls and transaction logs) - but explaining how to use those is beyond the scope of what I can do here. Contact the vendor for instructions.
  • If no, restore the full backup and transaction logs as a database with a different name. (Don't overwrite the existing database.) You'll be able to get an up-to-the-second copy of the object before the delete happened, but you'll need to use the stopat part of the restore command to specify when to stop restoring the commands. You need to stop before the delete happened.
  • If no, go grab a copy of a log reader utility like Quest LiteSpeed or Apex SQL Log. These utilities can connect to the database server, examine the log file, and help you undo transactions. I'm not sure if the demo versions will work, but the paid ones definitely will.
  • If no (not in full recovery mode), restore the last full backup as a database with a different name. (Don't overwrite the database you've already got.) From there, you'll be able to restore whatever records were online at the time of the backup, but you'll lose all of the changes since.

Here are the steps to recover deleted records in SQL Server table using transaction logs

  • USE Databasename. GO. BACKUP LOG [Databasename] ...
  • USE Databasename. GO. Select [Current LSN] LSN], [Transaction ID], Operation, Context, AllocUnitName. ...
  • USE Databasename. GO. SELECT. ...
  • USE Databasename. GO. RESTORE DATABASE Databasename_COPY

Or to Restore That Important Missing File or Folder:

Type Restore files in the search box on the taskbar, and then select Restore your files with File History.

Look for the file you need, then use the arrows to see all its versions.

When you find the version you want, select Restore to save it in its original location





Your Answer

Interviews

Parent Categories