Search code examples
sql-server-2005t-sqldatabase-mirroring

TSQL to know if database mirroring is setup for both PRimary and secondary server


I have Database mirroring setup between two SQl 2005 servers (no witness). Using Tsql, I want to find if there is a user database on both primary and mirror server. I can use the following on mirror:

select * from sys.databases where state <>1 and database_id>4

What should i use for Primary server?


Solution

  • Use the dmvs associated with database mirroring

    For example, sys.database_mirroring