Wednesday 1 October 2008

Is there a way to determine node name in SQL using QA?

Customer Question:
I am running a 2-node SQL 2000 cluster in Active / Passive mode. Is there a way in SQL to determine what the node name would be, that runs the instance of SQL at any point in time?

Method :1
For SQL Server 2005 clustered instances, we can use a new serverproperty
select serverproperty('ComputerNamePhysicalNetBios')

->This will return the NetBIOS name of the local computer on which the instance of SQL Server is currently running
->Also, now in SQL 2005, the errorlogs tells us the actual node name too.

Method :2
DECLARE @NodeName sysname
EXEC master.dbo.xp_regread @rootkey='HKEY_LOCAL_MACHINE',
@key='SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\',
@value_name='ComputerName', @value=@NodeName OUTPUT
PRINT @NodeName

No comments: