Sunday, February 20, 2011

T-SQL Queries to find SQL Server Cluster Nodes and Shared Drives

In one of my earlier post's "Finding Cluster Nodes or Cluster Name" , I had told about the query which can be used to find the name of the node on which the SQL Server Instance is currently running.
Here are more such SQL Server cluster related T-SQL queries which helps in finding SQL Server Cluster Nodes and their shared drives.
  1. Find name of the Node on which SQL Server Instance is Currently running
    SELECT SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS [CurrentNodeName] 
    If the server is not cluster, then the above query returns the Host Name of the Server.

  2. Find SQL Server Cluster Nodes
    a. Using Function
    SELECT * FROM fn_virtualservernodes() 

    b. Using DMV
    SELECT * FROM sys.dm_os_cluster_nodes 

  3. Find SQL Server Cluster Shared Drives
    a. Using Function
    SELECT * FROM fn_servershareddrives() 

    b. Using DMV
    SELECT * FROM sys.dm_io_cluster_shared_drives

17 comments:

  1. thank you these comments are very useful.

    ReplyDelete
  2. Thanks. That was great!

    ReplyDelete
  3. Is there code to return the name of the cluster which the instance is hosted on? Not the name of the nodes, but the higher level cluster name which the groups/nodes sit under.

    ReplyDelete
  4. Select @@ServerName will give you the virtual cluster name.

    ReplyDelete
  5. Good stuff bro!

    ReplyDelete
  6. Select @@ServerName will not give you cluster name, but cluster_node/instance_name.. I do not know how to pull cluster name using T-SQL though...

    Ed

    ReplyDelete
  7. Very cool, very helpful, thanks so much!

    ReplyDelete
  8. Excellent!! Thank you very much!!

    ReplyDelete
  9. Microsoft SQL Server is the base of all of our in-house servers. We use it to access all of our internal and external data that comes from Verint and other places. It solves our need to store the data that we have in one location and to create a data warehouse on top of it. thank you~ Charlotte W. from big data analytics

    ReplyDelete
  10. It’s a very easy on the eyes which makes it much more pleasant for me to come here and visit more often.
    marsbahis
    trendbet
    galabet

    ReplyDelete
  11. Universial Studios offers one of the best studio in Hollywood, they also make great films* best holiday loans for bad credit from UnitedFinances

    ReplyDelete