Sunday, May 15, 2016

Bringing Mirrored ( no witness) SQL database online after principal failed

In Microsoft SQL server, there is a high availability feature called Database Mirrioring which is quite old technology. 

If you have tried to configure a Database Mirroring with only 2 SQL servers ( SQL server 2014 in this example) with no witness, you may find that the mirrored database is not accessible after principal database offline. 

Now, we are going to bring it online.

After principal database is offline, the mirrored database is like below and no accessible.


Run SQL statement

alter database @dbname set partner off


Then you see something like below:


 The database is still not accessible.

Run SQL statement

restore database @dbname with recovery


 Now, the mirrored database is accessible. Your application  can use it again after data loss may exist.

Please note that if you try to create  database mirror using this database as principal, you will get error 1478. Please truncate the transaction log of this database first.









No comments:

Post a Comment