SQL Stuff

Get All Servers Involved In A Mirror

Here’s some quick sql logic to show you the Servers involved in a database mirror. This does not show you which is Principal or Mirror, but only the server names. The query shows “Server1” and “Server2” plus the “Witness”, but that it. It’s meant to give you the Server names.

 use master;
set nocount on
[Server1] = @@servername
,	[Server2] = replace(reverse(right(reverse(mirroring_partner_name), len(mirroring_partner_name) - charindex('.',reverse(mirroring_partner_name),10) + 0)), 'TCP://', '') ,	[Witness] =	case
when '' then 'NOT CONFIGURED'
else replace(reverse(right(reverse(mirroring_witness_name), len(mirroring_witness_name) - charindex('.',reverse(mirroring_witness_name),10) + 0)), 'TCP://', '') end
mirroring_partner_name is not null

Categories: SQL Stuff

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s