Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mirroring information for all databases on a SQL Server
SELECT DISTINCT
CAST(SERVERPROPERTY('ServerName') as nvarchar(100)) AS Principal,
m.mirroring_partner_instance AS Mirror,
DB_NAME(m.database_id) AS DatabaseName,
SUM(f.size*8/1024) AS DatabaseSize,
CASE m.mirroring_safety_level
WHEN 1 THEN 'HIGH PERFORMANCE'
WHEN 2 THEN 'HIGH SAFETY'
END AS 'OperatingMode',
RIGHT(m.mirroring_partner_name, CHARINDEX( ':', REVERSE(m.mirroring_partner_name) + ':' ) - 1 ) AS Port
FROM sys.database_mirroring m
JOIN sys.master_files f ON m.database_id = f.database_id
WHERE m.mirroring_role_desc = 'PRINCIPAL'
GROUP BY m.mirroring_partner_instance, m.database_id, m.mirroring_safety_level, m.mirroring_partner_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment