May 20th, 2019
February 26, 2021
Ever since the concept of the database came into existence, the data storage has undoubtedly become more convenient and organized than it used to be while the flat file system was previously in use. With the elimination of the cons associated with a flat file system such as redundancy, inconsistency, limited data sharing, etc. database system has proven to be a reliable method for storing and sharing data. However, no matter how good a system is, perfection can never be reached. And no matter how robust the storage system is, there is always a room for corruption. Therefore, it is important to have a backup so that the database can be restored and recovered. This article contains information about creating a backup as well as the procedure to restore MS SQL Server database. Make sure that you have SQL Server Database Engine as well as SQL Server Management Studio installed in your computer system.
In order to create a backup, follow these basic steps:
Step 1: In the Object Explorer, select the database for which you want to create a backup. Right click on the selected database, an option list will appear. Select Tasks and then Back Up.
Step 2: As you click on Back Up, a dialogue box will appear. Add a destination where you want you to store the backup file.
Step 3: After adding the destination path. Click on OK button
It is to be noted that the procedure given above is the easiest way to create a backup of the database. However, there are other ways to do the same. One such way is using T-SQL. In the Back Up Database dialogue, click on Script button. It will expand a list. Now it’s your call on how you want to save the script, to new query window, file, clipboard or a job.
The SQL query will be something like this:
BACKUP DATABASE [SysInfoToolDB] TO DISK = N’d:\sql\SysInfoToolDB.bak’ WITH NOFORMAT, NOINIT, NAME = N’SysInfoToolDB-Full Database Backup’, SKIP, NOREWIND, NOUNLOAD, STATS = 10
After the above query is saved, it can be executed anytime and so it will come in handy in the case back up is needed multiple times.
The entire procedure of restoring the MS SQL Server Database can be carried out in two ways. You can opt to recover the corrupt database using either RECOVERY or NO-RECOVERY according to your need. It should be kept in mind that using the recovery option will rollback the changes that were not committed. This will be quite handy in making the database consistent and so you will be able to safely bring the database online. The no-recovery method, however, omits the rollback for uncommitted changes allowing further restore stages to continue from the restore point. In order to get a complete insight about these two options, refer to the official Microsoft’s documentation by following the hyperlink below: https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/ms191455(v=sql.105)
This is the default method by which you can restore the database to a previously saved state.
Step 1: Right-click on Databases in the object explorer and select Restore Database.
Step 2: Select the backup file of the database that you have previously created in order to restore it.
Step 3: In the left panel, Click on Options. Here you can select the options related to restoration, recovery state and server connections.
Step 4: Select the recovery state and by default, choose the Restore with Recovery state. In order to use No-Recovery method, select Restore with NORECOVERY. Click on OK button.
This is the simplest way to restore a database to a previously saved state. You can also use scripting method using T-SQL. In order to do that, in the Restore Database dialogue box, click on the Script button select where you want to open the script. Click on OK button.
The sql query will look something like this:
RESTORE DATABASE [SysInfoToolDB] FROM DISK = N’d:\sql\SysInfoToolDB.bak’ WITH FILE = 1, NOUNLOAD, STATS = 5
For No Recovery:
RESTORE DATABASE [SysInfoToolDB] FROM DISK = N’d:\sql\SysInfoToolDB.bak’ WITH FILE = 2, NORECOVERY, NOUNLOAD, STATS = 5
RESTORE LOG [SysInfoToolDB] FROM DISK = N’C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Backup\SysInfoToolDB_LogBackup_2019-05-16_10-24-25.bak’ WITH FILE = 1, NOUNLOAD, STATS = 5, RECOVERY
Sometimes what can cause qualms to a person is that the database file is corrupted and no backup has ever been created. For this troublesome scenario, SysInfoTools’ MS SQL Database Recovery software can be a silver bullet as this application software can recover the data from a corrupt MS SQL Database File.
It is probably likely that a user faces hindrance while restoring the database because of corruption in the backup file. And the worst part is, there is no manual method to repair SQL database backup file. In such a situation, you can use SysInfoTools’ SQL Backup Recovery software to restore MDF and NDF databases from SQL Server backup file. Then the MS SQL Database Recovery tool can be use to recover the data from those database. Also, the SQL Backup Recovery can successfully recover the data from compressed backup files.
Recommended to read: How to Restore Master Database in SQL Server