Step 1: Create a DatabaseĮxecute the following query to create a database named ‘RecoverDeletedRecords’ and a table named ‘Employee’:įigure 5 – Current LSN of Transaction Log Then, we will find deleted data and recover it using LSN. In this section, we will create a test database and a table on which we will run a DELETE operation. Steps to Recover Deleted Records from SQL Table with LSN In this example – we’ll create a database and a table, insert rows into the table, delete some rows, get information about deleted data, and recover the data. Let’s take an example to understand how you can use the log sequence number method to recover deleted table records. You can construct restore sequences by using the LSN of a log record at which a significant event occurred. In that case, skip to the next method.Įach SQL Server transaction log record is uniquely identified by a log sequence number (LSN). Note: This method won’t work if the transaction log backup is corrupted or missing. Method 1 – Using Log Sequence Number (LSN) Methods to Recover Deleted Table Records in SQL Server Only the delete operations can be recovered. Note: The truncate operations cannot be recovered. If you’ve accidentally executed a DROP or DELETE command against a table with a wrong WHERE clause and lost important records, you can recover them by using any of the following methods.