If you want to roll-back data which were removed by running the query – DELETE accidentally in the Microsoft SQL Server, then this article is meant for you. The method describe in this write-up will tell you how to retrieves data from log file in SQL Server 2017 / 2016 / 2014 / 2012 / 2008 / 2008 R2 / 2005.
So, let’s get started !
Why We Need to Get Data from SQL Server Log File?
If you are not aware with the importance of Log file then, I will tell you it is a very prominent part of every server database. Likewise, the SQL Transaction Log File (.ldf) is a very crucial component of Microsoft SQL Server. Adding to it, whenever a query is executed or any modification takes place, a record gets saved in the Transaction Log file. All the record entries saved in the sequential manner. It plays major role during the SQL Server Recovery after a disaster has happened. To do the same, make sure SQL Log file must be remain uncorrupted.
Although, when there is a requirement of data recovery, we first consider the help of SQL backup file. But, this data restoration from backup file not always work. For example, if you just took a backup of database on Monday and somehow some entries get deleted from the same database on Thursday. So, if you are planning to restore the database then, you will not get the data of Tuesday, Wednesday, Thursday as you take last backup on Monday. In such situation, you need to take help of Log file of SQL Server.
In order to get data from SQL Server Log file, you need to use the most popular SysTools SQL Transaction Log Viewer. Its function is to open & scan the Log file and displays its transactions – Insert, Update, Delete on the software panel. Afterward, one can export the deleted records into the SQL Server environment or SQL compatible SQL scripts. Hence, in order to get data from SQL Server Log file follow the below steps.
Method to Retrieve Data from Log Files in SQL Server
Step 1: First of all, setup the software on your Windows system.
Step 2: This software is very much flexible. It gives you two options to scan a log file.
Online DB Option – This option is used to directly browse the log file from SQL Server. All you need to enter the Server name, Authentication Type and choose a database. Afterward, the tool automatically upload the LDF file of the selected database.
Offline DB Option – The Offline DB option can work for the users who do not have SQL Server installation in the system. This feature let you to manually enter the LDF as well as MDF file. The MDF file is required to analyse the schema.
Step 3: Once you have done with the above steps, the transactions – Insert, Update, Delete executed on the database gets appeared on the software panel.
Step 4: Afterward, click on Export option to roll back the deleted queries.
Step 5: Under the Export Filters, check the box corresponding to Delete. Afterward, you can select the date filters to recover deleted records of a particular timeline.
Step 6: The software allows to restore data into three different modes – SQL Server Database, SQL Server Compatible Scripts, CSV. If you opt for SQL Server Database, then enter the Server Name, Authentication and login Password for the further process. In rest of the two modes, you do not need to enter the additional details.
Step 7: If you opt for SQL Scripts and CSV then, you need to provide the location to store the files.
Step 8: At last, click on Export to get data from log file in SQL Server.
Bringing It All Together
This guide is all about how to get data from Log file in SQL Server 2017 / 2016 / 2014 / 2012 / 2008 / 2008 R2 / 2005. So, if you ever stuck in the situation where you need to restore deleted records , then take the help of above mentioned SQL Log Analyzer. It supports data recovery of Log file of every MS SQL Server version.