It is not difficult to recover accidentally deleted data in SQL Server. It can be recovered from the transaction log. However, this recovery requires two prerequisites:
SQL database data recovery method:
1. At least one A previous full backup of the database was accidentally deleted.
2. The recovery mode of the database is "Full".
Regarding these two prerequisites, there will be three situations:
Situation 1. If these two prerequisites exist, it can be restored in only three steps through SQL statements (without the help of Third-party tools.
a) Back up the transaction log of the current database: BACKUP LOG [database name] TO disk= N'backup file name' WITH NORECOVERY
b) Restore a transaction log before it was accidentally deleted Full backup: RESTORE DATABASE [database name] FROM DISK = N'full backup file name' WITH NORECOVERY, REPLACE
c) Restore the database to the time point before accidental deletion: RESTORE LOG [database] FROM DISK = N'The name of the log backup file in the first step' WITH STOPAT = N'The time point before the accidental deletion', RECOVERY
Case 2: If the first prerequisite does not exist and the second prerequisite exists, Requires third-party tools.
Case 3: If the second prerequisite does not exist, recovery cannot be performed. Therefore, be sure to set the database recovery model to "Full".
In the second case, you need to find a third-party tool.
Recommendation: Finally found Recovery for SQL Server on officerecovery.com. Although it is also a commercial software and needs to be purchased, the Demo version can recover data as long as the database file does not exceed 24Gb. Fortunately, my friend's database file is not large and I used it to recover accidentally deleted data.
The above is the detailed content of How to recover deleted data from sql database. For more information, please follow other related articles on the PHP Chinese website!