sql server – How to check with TSQL if I’m connected to an Azure Managed Instance in a Failover Group?

How can I check with TSQL if I am connected to an Azure Managed Instance that’s in a Failover Group?

For Always-On we can use this:

SELECT SERVERPROPERTY('IsHadrEnabled')

But in the case of Azure Managed Instances in a Failover Group, that returns 0.

It’s easy to check if I’m connected to a secondary, because the databases will be read-only. But if I’m connected to the primary, how can I tell?

I also tried:

SELECT SERVERPROPERTY('IsClustered')

Which returns 1 for standalone servers, and seems to returns null for all Azure Managed Instances (regardless of if it’s in a failover group or not) and all Azure SQL databases.

Read more here: Source link