Friday 1 April 2016

TSQL How to Manually Failover a SQL Server Database Mirroring Session

USE master;
ALTER DATABASE [Database_Name] SET PARTNER FAILOVER
The mirror database becomes the principal and the principal database becomes the mirror, clients are disconnected from the former principal database and active transactions are rolled back:
“Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.”
If you try to manually failover SQL Server database mirroring session when the database is NOT in the SYNCHRONIZED state, you will get an error message:
Msg 1422, Level 16, State 2, Line 2
The mirror server instance is not caught up to the recent changes to database “Database_Name”. Unable to fail over.

No comments:

Post a Comment