• facebook
  • twitter
  • linkedin

Read time 4 minutes

An SQL Server Administrator performs database restoration when some information from the database is missing. The restoration procedure requires the SQL backup file and transaction logs to restore the database data as it was present before deletion. In some cases, when the restoration is complete, and you try to access the data, then you may get the following error message:

Database ‘DB5343’ cannot be opened. It is in the middle of a restore.

The error occurs because the administrator used the NORECOVERY mode for the restoration and it does not allow the usage of the database. So, you should now use WITH RECOVERY mode for database restoration as it will make the database accessible to the user.

Instant Solution

Download an automated solution Kernel for SQL Database Recovery for fix Database cannot be opened error in SQL Server.

T-SQL statement for restoring database WITH RECOVERY option

Although the WITH RECOVERY option is activated by default with the full restore procedure, you can mention in the command also.

RESTORE DATABASE DB5343 FROM DISK = ‘C:\DB5343.BAK’
WITH RECOVERY
GO

Recover a database from the ‘restoring’ state

If the database is in ‘restoring’ state and is not available to users, you should run the command to make it accessible to users.

RESTORE DATABASE DB5343 WITH RECOVERY
GO

Restore multiple backups using WITH RECOVERY

SQL Server restoration using NORECOVERY option can restore the database from numerous back-ups, except in the last step. Using WITH RECOVERY in the last action restores all transaction logs to bring the database online.

RESTORE DATABASE DB5343 FROM DISK = ‘C:\DB5343.BAK’
WITH NORECOVERY
GO
RESTORE LOG DB5343 FROM DISK = ‘C:\DB5343.TRN’
WITH RECOVERY
GO

After completing the restoration process using WITH RECOVERY command, the database should be online and accessible.

Restore using SQL server management studio

You can perform the task using the WITH RECOVER option using SQL Server Management Studio. Here is the process:

  1. Start the Studio from the program and go to Databases in the menu list. Right-click the databases and click the Restore database option.
  2. Select the option ‘From Device’ and then click the Browse button the go to the location of the backup file which you had recently created.
  3. In the Specify Backup wizard, select the backup file and click the OK button.
  4. Now, in the destination for the restore section select the database where you want to put the recovered data.
  5. In the Restore options, check the option ‘Overwrite the existing database (WITH REPLACE).’
  6. In the Recovery state, select the option ‘Leave the database ready to use by rolling back uncommitted transactions. Additional transactions logs cannot be restored’.
  7. Click OK and let the restore procedure complete.
  8. Perform the same procedure for each backup file which you need to restore for the database.

Check if the database is live and accessible to users

After using the two methods, you can restore the database in a healthy state, but if any of these methods do not work, then you need to use a professional SQL Recovery tool which can remove the error from SQL database and restore it in full health. Kernel for SQL Database Recovery is a competent software which can access the database files of SQL server and safely recover it.

Kernel for SQL Database Recovery

The software relieves you from running any restore procedure for the SQL database, as it can access the MDF/NDF files from their original location and recover whole information from them even if any object was deleted. When you repair corrupt SQL Database you even do not need to mention the version of SQL Server of the associated database file as it can automatically find it. After recovering the database, you can choose the required data and save them directly to the live SQL Server.

All the tables, rules, functions, dependencies, triggers, deleted records, etc. will be present in full health after recovery. Here the vital features of the software that will help you in effective recovery.

  • Recovery of corrupt and inaccessible data from the SQL Database files
  • Supports of all version of SQL Server 2019, 2017, 2016, 2014, 2012, 2008 R2, 2008, 2005 and 2000.
  • Full recovery of MDF/NDF files irrespective of their size.
  • Preview of the selected data before saving.
  • Automatic detection of SQL Server versions.
  • Recover of MDF/NDF file data to a live SQL Server.
  • Creation of a separate backup file in script format.
Related Posts