troubleshooting Question

T-SQL for SQL Server 2008 to detemine who is Principal and who is Mirror

Avatar of Carl Webster
Carl WebsterFlag for United States of America asked on
Microsoft SQL Server 2008
15 Comments1 Solution2230 ViewsLast Modified:
I have setup mirroring for a database using SQL Server 2008 SP2.

When I look in the SQL Mgmt Studio my SQL1 server shows as (Principal, Synchronized) and my SQL2 server shows as (Mirror, Synchronized/Restoring...).

When I issue the follow T-SQL:

USE [Master]
GO
ALTER DATABASE [$(varDB)] SET PARTNER FAILOVER
GO

The GUI shows the reverse.  i.e SQL2 is now Principal and SQL1 is now Mirror.

Is there some T-SQL code I can use to show the Principal and Mirror status for the database?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 15 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros