Recovery is the process of copying backed up data and putting recorded transactions into MS SQL Server data. Simply put, this is the process of retrieving the backup file and returning it to the database.
Database recovery can be done in two ways.
Method 1: Use T-SQL
The following syntax is used to restore databases.
Restore database from disk = ''
For example
The following command is used to restore the database named TestDB with a backup file named TestDB_Full.bak located at address D: if you choose to overwrite the current database.
Restore database TestDB from disk = ' D:TestDB_Full.bak' with replace
If you create a new database using this recovery command and there is no path or file to record history on the server above, use the command below. Make sure the path D: Data exists .
RESTORE DATABASE TestDB FROM DISK = 'D: TestDB_Full.bak' WITH MOVE 'TestDB' TO 'D:DataTestDB.mdf', MOVE 'TestDB_Log' TO 'D:DataTestDB_Log.ldf'
Method 2: Use SQL Server Management Studio SSMS
Step 1 : Connect to the database named TESTINSTANCE and right click on the folder, select Restore Database to appear as shown below.
Restore the database by selecting after right clicking
Step 2 : Select Device and select the path to open the backup file as shown below.
Find the place where the backup file was saved when you created it before
Step 3 : Click OK and the screen below will appear.
Select the recovery database and the previously created backup file
Step 4 : Select Files in the left corner of the screen, the following dialog box will appear.
File information for database recovery process
Step 5 : Select Options in the left corner and click OK to start restoring TestDB database as shown in the picture below.
Successfully restored TestDB database