Agent Jobs

Find SQL Databases That Are Mirrored

Here’s some quick SQL logic to get a list of databases that are currently being mirrored on your server. It also shows the mirror state of each database including the current server (where you running the script) role as to if it’s the Principal or the Mirror including the secondary server name which is the mirror server plus the port being used for the mirror.


use master;
set nocount on
select
'database name' = DB_NAME(database_id)
, 'mirror state' = mirroring_state_desc
, 'current mirror role' = mirroring_role_desc
, 'partner server name' = mirroring_partner_name
from
sys.database_mirroring
where
mirroring_guid is not null

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s