Saturday, November 23, 2024
Home » Database » How to View and Restore SQL Server Backup File

How to View and Restore SQL Server Backup File

  author
Written By Aswin Vijayan
Mack John
Approved By Mack John  
Published On January 18th, 2024
Reading Time 3 Minutes Reading

Introduction:

SQL Server provides the option to create and restore the database from backup whenever required. This will help users to prevent data loss in case of disaster. The SQL Server keeps the backup of its database in a separate backup file i.e .bak file. This backup file can be saved on a separate disk drive. The backup file cannot be viewed directly by opening it, you need to restore it to view its database.

SQL Server provides different options for creating and restoring a database from .bak file. There are two different ways that we can use to restore SQL .bak file.

Tip: If you want to recover corrupt .bak file of SQL Server then, you can utilize SQL Backup Recovery tool.

Domain to Domain

Methods to View SQL Server .bak File

In order to recover database from .bak file, the SQL Server provides two different ways to view and restore the backup file from a specific location.

    1. By using T-SQL
    2. By using SQL Server Management Studio

We can use above options to restore SQL Server .bak file. So, first of all, we will know how to restore SQL Server .bak file using the T-SQL script.

Restore SQL Backup File Using T-SQL :

To restore a .bak file in SQL Server, you need to first create a backup of your database and then you can restore it. If you have already created a full database backup then you can use below T-SQL script to restore the full database backup from a .bak file.

RESTORE DATABASE AdventureWorks FROM DISK = 'E:\AdventureWorks.BAK'
GO

the above T-SQL script will help you in restoring the database from the specified location and will create and restore the database if it does not already exist.

Restore SQL .bak File Using Management Studio:

To restore database using SQL Server management studio follow the below steps:

  1. Connect to SQL Server using Windows or mixed mode authentication.
  2. In object explorer, Select the Databases and Right click on it then click on Restore Database…
  3. Now, Specify the source and location of the backup sets by choosing either from the database or from the device.
  4. In ‘Specify backup’ window, Set the ‘Bakup media’ and click on Add to select the .bak file which is to be restored.
  5. Now, browse the backup file you want to restore and click on Ok then again click on Ok to complete the process.
  6. After performing the above steps a new window will appear by displaying the restoration process completed successfully.

The above procedure will help you in restoring the backup file using SQL Server management Studio.

Conclusion:

In this section, we learned, how to view and restore corrupted bak file in SQL Server database and how we can use T-SQL script and SQL Server Management Studio to restore a database using .bak file.

SQL Server uses different clauses to restore its database from a .bak file. In this section, we have restored a full backup, if someone trying to restore differential and transaction log backup, then do not forget to use With Norecovery clause in your statement.