Read time 4 minutes

Summary: This content discusses SQL Server database restoration methods, particularly addressing the ‘Database cannot be opened’ error. It highlights using the WITH RECOVERY mode for successful restoration, provides T-SQL statements, and recommends a professional tool, Kernel for SQL Database Recovery, for efficient database repair and recovery.

A SQL Server Administrator undertakes the task of database restoration in situations where certain data is absent from the database. The restoration process entails the utilization of both the SQL backup file and transaction logs to recover the database to its state before the data was deleted. Occasionally, following the restoration process, attempts to access the data may result in the appearance of the subsequent error message:

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

The error was triggered because the administrator employed the NORECOVERY mode during the restoration process, which restricts database usage. To resolve this issue, it is advisable to switch to the WITH RECOVERY mode for database restoration, as it will enable user access to the database.

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 a ‘restoring’ state and isn’t accessible to users, you should execute the command to grant users access to it.

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 execute the task by utilizing the WITH RECOVER option within SQL Server Management Studio. The procedure is as follows:

  1. Open the Studio application, navigate to the menu list, and select “Databases.” Next, right-click on the “databases” entry, and choose the “Restore database option.”
  2. Choose the ‘From Device’ option and then click the ‘Browse’ button to navigate to the location where you recently saved the backup file.
  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 eliminates the need for you to perform any restoration procedures on the SQL database. It has the capability to retrieve complete information from the original MDF/NDF files, even if any objects were deleted, directly from their original location. 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.

Following a successful recovery, all elements, including tables, rules, functions, dependencies, triggers, and deleted records, will be fully restored to their original state. These are the essential components of the software that facilitate a robust and efficient recovery process.

  • 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.
Kernel for SQL Database Recovery