Home » SQL Server Error : 927, Severity: 14. Database ‘%.*ls’ cannot be opened. It is

SQL Server Error : 927, Severity: 14. Database ‘%.*ls’ cannot be opened. It is

  • by

SQL Server Error : 927 Details


SQL Server Error: 927
Severity: 14
Event Logged or not: No
Description:
Database ‘%.*ls’ cannot be opened. It is in the middle of a restore.
Severity 14 Description:
Indicates security-related errors, such as permission denied.

Steps to recreate or create this error

  1. Create or select Database on primary for mirroring.
  2. Took full backup and log backup.
  3. Restored full and log on secondary in NORECOVERY mode
  4. Tried configuring mirror from primary.
  5. Then click “Start Mirroring”
  6. And here volla….  you  may will get the error: 927.
Actually this is not an error, this msg tell us that the database, for which you want to configure the mirror, is not fully restored and it is in the middle of the restore.

Reading sql server error log location from SQL Query

Identifying SQL Server Error Log File used by SQL Server Database Engine can be done by reading SQL Server Error Logs. DBA can execute the XP_READERRORLOG extended stored procedure to read the SQL Server Error Log and search for its location used by the instance of SQL Server.

USE master
Go
xp_readerrorlog 0, 1, N'Logging SQL Server messages in file', NULL, NULL, N'asc'
Go

The parameters for XP_READERRRORLOG are:
1. Value of error log file we would like to read. values are 0 = current, 1 = last one before current, 2 = second last before current etc…
2. Log file type:- 1 or NULL = error log, 2 = SQL Agent log
3. Search string 1:- String one you want to search for
4. Search string 2:- String two you want to search for to further refine the results
5. start time for Search
6. end time for search
7. Sort order for search results:- N’asc’ = ascending, N’desc’ = descending

By default, we have 6 Server Error Logs kept but we can increase the number of SQL Server Error Logs from the default value of six.

For other ways to read and find error log location please our artcile https://sqlserver-dba.co.uk/error-log/sql-server-identify-location-of-the-sql-server-error-log-file.html

Solution for Resolving the Error

1. For this we need to restore the latest transaction log backup on mirror server/mirror node. Then click on start mirroring again at principal node,  and it will work.
2. If we have restored the full backup and the latest log backup as well and we are still getting error 927, then we need to execute the command
On Mirror Server we need to run the SQL below
ALTER DATABASE <Database_Name> SET PARTNER = ‘TCP://<Principal Server>:5022’ 
Exp. : ALTER DATABASE TestDB SET PARTNER = ‘TCP://Testserver_Principal:5022’
On Principal Server we need to run the SQL below
ALTER DATABASE <Database_Name> SET PARTNER = ‘TCP://<Mirror Server>:5022’
Exp. ALTER DATABASE TestDB SET PARTNER = ‘TCP://Testserver_Mirror:5022’
Now, after executing of the above SQL commands on mirror and principal server, mirroring will be configured successfully.

Additional information:

Errors which can be encountered are microsoft sql server error 927 restoring is for mirroring database not ready for starting the mirror configuration.
This error can occur in sql server 2019 mirroring error 927 .

In sql server database mirroring error 927 is very common and can be quickly resolved with two options given above.
ms sql server error 927 or  error 927 in sql server is one of simple error encountered while configuring sql mirroring.

SQL Server Error Code and solution summary


SQL Server Error: 927
Severity: 14
Event Logged or not: No
Description:
Database ‘%.*ls’ cannot be opened. It is in the middle of a restore.

Solutions here would be
1. For this we need to restore the latest transaction log backup on mirror server/mirror node. Then click on start mirroring again at principal node,  and it will work.
2. If we have restored the full backup and the latest log backup as well and we are still getting error 927, then we need to execute the command
On Mirror Server we need to run the SQL below
ALTER DATABASE <Database_Name> SET PARTNER = ‘TCP://<Principal Server>:5022’ 
Exp. : ALTER DATABASE TestDB SET PARTNER = ‘TCP://Testserver_Principal:5022’
On Principal Server we need to run the SQL below
ALTER DATABASE <Database_Name> SET PARTNER = ‘TCP://<Mirror Server>:5022’
Exp. ALTER DATABASE TestDB SET PARTNER = ‘TCP://Testserver_Mirror:5022’
Now start mirroring and it will work.

Leave a Reply

Your email address will not be published. Required fields are marked *