Current location - Music Encyclopedia - Today in History - How to view the previously executed sql statements through the sql log?
How to view the previously executed sql statements through the sql log?
If the database is in full recovery mode, you can view it through Log Explorer.

Just search for specific purposes.

Using Log Explorer to View and Recover Data

Log Browser 4. 1. Log viewing tool available for SQL Server2005.

How to use:

Open the log browser-> Attach log file->; Select SQL Server server and login method-> Connect->

Select the database in Database Name-> Additional-> Browse-> Check the log-> You can see the log record.

To restore: right-click the log that records the undo transaction-> Select the save file name and path-> Then open the file to query the execution of analyzer.

T-sql code will do.

For example, if the log is a delete table, where ..., the generated file code is an insert table. ....

Then put the code inserted into the table into the query analyzer for execution, and the data can be recovered.

-

-How to recover deleted/updated data?

-

1 connect to the Db of the deleted database.

Open the log browser and select File->; "attach log file"->; Select the server and login method-> "connect"->; Select "database"->; "Additional"

2 check the log

Select the "browse" item in the left operation item dialog box->; "view the log"->; You can see the current logging.

3 Recover data

Right-click the log record and select "Undo Conversion"-> "Select File Name and Path to Save"->; Then open the file to query the execution of analyzer.

T-sql code will do.

For example, if the log is a delete table, where ..., the generated file code is an insert table. ....

-

-Log Explorer recovers data after deleting and truncating tables.

-

1 connect to the Db of the deleted database.

Same operation as above

2 recovery method

1) Select the "salvage dropped/truncate" menu, and select the table name and the date of dropped/truncate in the dialog box on the right.

In the file name, select the storage location of the footprint that generated the insert statement, and the condition selects whether it is discarded or truncated.

Finally, click "create" to generate an insert statement and execute the generated statement in the query analyzer.

2) select "ViewDDL command" menu->; Select "truncate table" action item->; Click "salvage"->; Generate report->; Execute in the query analyzer

-

-several problems in the use of logexplorer.

-

1) Make a full/differential/log backup of the database.

If you choose to delete inactive entries in the transaction log during the backup process

When you try to read the log using Log Explorer again, you will be prompted that you have not found a log recorder that matches the filter. If you want to view the unfiltered data, you will not see the record just now.

If you do not choose to delete inactive entries in the transaction log

When you try to read the log using Log Explorer again, you can see the original log and restore it.

2) Some data in one of the tables has been modified. At this time, you can use the log browser to read the log and restore it.

3) Then restore the backup. (Note: Recovery means disconnecting the log browser from the database or connecting to other data.

Otherwise, the database will be occupied and cannot be recovered)

After recovery, open the log resource manager, prompting that no log recorder matching the filter has been found. Do you want to view the unfiltered data? Select Yes to view the log record just modified in 2, so it cannot be recovered.

4) Don't use the backup function of SQL for backup, or your log will be destroyed.

The correct backup method is:

Stop SQL service and copy data files and log files for file backup.

Then start the SQL service and use the log explorer to recover the data.