This script is so simple you’ll start off by asking why you’d ever use it. Then you’ll use it and wonder why no one gave this to you as part of your new-hire orientation at your first DBA job. The truth is that in larger environments there will always be times when you’re asked what the active node is, are two instances running on the same node, what nodes are in that cluster, what drives belong to what instance, etc… Here’s your answer.
SELECT VirtualServerName = SERVERPROPERTY('ServerName') , ActiveNode = SERVERPROPERTY('ComputerNamePhysicalNetBIOS') , PassiveNode = CASE (SELECT COUNT(*) FROM sys.dm_os_cluster_nodes WHERE NodeName <> SERVERPROPERTY('ComputerNamePhysicalNetBIOS')) WHEN 0 THEN 'Stand-Alone' WHEN 1 THEN (SELECT NodeName FROM sys.dm_os_cluster_nodes WHERE NodeName <> SERVERPROPERTY('ComputerNamePhysicalNetBIOS')) ELSE Cast((SELECT COUNT(*) FROM sys.dm_os_cluster_nodes WHERE NodeName <> SERVERPROPERTY('ComputerNamePhysicalNetBIOS')) as VarChar(2)) + ' Passive Nodes' END SELECT PassiveNodes = NodeName FROM sys.dm_os_cluster_nodes WHERE NodeName <> SERVERPROPERTY('ComputerNamePhysicalNetBIOS') SELECT ClusterDrives = DriveName FROM sys.dm_io_cluster_shared_drives ORDER BY DriveName
Hi Steve,
This is neat!!
Some times back, I have wrote a kind of script, but, with some additional details like domain, time zone etc., http://www.sql-server-citation.com/2013/04/collecting-host-machine-information.html . Don’t surprise with the use of reg read as this was intended to use on SQL 2000 🙂
Thanks. This script I use for adding files, figuring out all the possible owners of the instance, etc. It’s more of a quick run kind of thing.
I do have another script that grabs some more details, and I might merge some of what you do in with it when I get the time. Here’s what I have: Database Assessment
https://simplesqlserver.com/2013/05/11/database-assessment-2/
Thanks!
Steve