Determine Active Node in SQL Failover Cluster

David Boike picture David Boike · Apr 22, 2009 · Viewed 40.7k times · Source

Does anyone know how to determine the active node of a SQL Active-Passive Failover Cluster programmatically from T-SQL?

@@SERVERNAME only returns the virtual server name, which is identical from both nodes.

I don't plan to make any decisions based on the data - I trust the failover to do its thing - but I would like to include the information in an event log so I can tell which node in the cluster was active when the event occurred, or help determine if exceptions come up as a result of a failover.

Answer

Stu picture Stu · Apr 22, 2009
Select ServerProperty('ComputerNamePhysicalNetBIOS')