Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server failover cluster - determine active node

Is there a way to programmatically determine which node in a SQL Server failover cluster is the active node? Or at least determine whether the current machine is the active node?

I have a Windows program which runs on both physical nodes in a failover cluster, but that should operate differently depending on whether it is running on the active node. Part of the reason is that this program should not run simultaneously on the inactive and the active node.

(I've read a bit about making the program cluster aware, but that seems heavily overkill for this simple scenario.)

like image 379
Kalle Avatar asked Dec 20 '10 16:12

Kalle


1 Answers

From SQL Server:

Select ServerProperty('ComputerNamePhysicalNetBIOS')

You can also access it through the Microsoft.SqlServer.Management.Smo Namespace as shown here.

like image 51
Joe Stefanelli Avatar answered Sep 30 '22 06:09

Joe Stefanelli