Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Other Technologies / Clustering / February 2006

Tip: Looking for answers? Try searching our database.

sql 2005 howto find virtual server name

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
melanie - 20 Feb 2006 11:19 GMT
Hello,

Does anybody know how I can programmatically detect the name of the virtual
server if sql 2005 is running on a cluster?

In previous sql versions I looked up the following registry entries:

Default instance: "HKLM\\SOFTWARE\\Microsoft\\MSSQLServer\\Cluster" REG_SZ
"ClusterName"
Named instance: "HKLM\\SOFTWARE\\Microsoft\\Microsoft SQL
Server\\<InstanceName>\\Cluster" REG_SZ "ClusterName"

It seems as if this changed for sql 2005, right?

Thanks a lot
Melanie
Mike Hodgson - 20 Feb 2006 22:17 GMT
The correct way to do this in SQL 2005 is the same as the correct way to
do it in SQL 2000.  That is,

   SELECT SERVERPROPERTY('MachineName')

No need to go messing about in the registry, simply ask SQL Server and
it will tell you.  Check out the SERVERPROPERTY() function in BOL - it's
packed full of useful goodies (so to is OBJECTPROPERTY(),
INDEXPROPERTY() and the INFORMATION_SCHEMA schema).

--
*mike hodgson*
http://sqlnerd.blogspot.com

>Hello,
>
[quoted text clipped - 14 lines]
>
>  
melanie - 21 Feb 2006 10:04 GMT
This works if I already have a connection to the sql server. But my problem is I have to find the name of the server I can connect to.

Any other solution?

Thanks
Melanie
 The correct way to do this in SQL 2005 is the same as the correct way to do it in SQL 2000.  That is,

   SELECT SERVERPROPERTY('MachineName')

 No need to go messing about in the registry, simply ask SQL Server and it will tell you.  Check out the SERVERPROPERTY() function in BOL - it's packed full of useful goodies (so to is OBJECTPROPERTY(), INDEXPROPERTY() and the INFORMATION_SCHEMA schema).

 --
 mike hodgson
 http://sqlnerd.blogspot.com

 melanie wrote:
Hello,

Does anybody know how I can programmatically detect the name of the virtual
server if sql 2005 is running on a cluster?

In previous sql versions I looked up the following registry entries:

Default instance: "HKLM\\SOFTWARE\\Microsoft\\MSSQLServer\\Cluster" REG_SZ
"ClusterName"
Named instance: "HKLM\\SOFTWARE\\Microsoft\\Microsoft SQL
Server\\<InstanceName>\\Cluster" REG_SZ "ClusterName"

It seems as if this changed for sql 2005, right?

Thanks a lot
Melanie

 
CShane - 21 Feb 2006 15:15 GMT
Not sure exactly what the situation is, but could cluster.exe help?  It can
list groups and resources.  What information IS known?  Do you know the node
name and are just looking for a virtual server name?  Do you want to list ALL
sql servers in the domain?  In short, what do you know and what are you
looking for?

Shane

> This works if I already have a connection to the sql server. But my problem is I have to find the name of the server I can connect to.
>
[quoted text clipped - 31 lines]
>
>  
Mike Hodgson - 21 Feb 2006 23:22 GMT
Ah, you want to enumerate SQL instances in order to connect to one?  To
me that screams SMO (SQL Management Objects) but it's been some time
since I played with SQL-DMO (SMO's previous incarnation) so I can't
offer any authoritative comments.

However, I'd be looking at the ManagedComputer class in the
Microsoft.SqlServer.Management.Smo.Wmi namespace (in .NET 2.0).  I think
given a ManagedComputer object, you can get a collection of the SQL
instances on that computer with the ServerInstances property.  But I
don't really know how you'd then get a connection string for one of
those particular instances to actually connect to.  Maybe someone in the
programming newsgroup can help.

If you want to just poke through the registry (I wouldn't recommend it)
I'd guess the virtual server name is stored in the ClusterName reg
string value of the HKLM\SOFTWARE\Microsoft\Microsoft SQL
Server\MSSQL.1\Cluster\ key.  I think the instance names would then be
stored under the HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\Instance
Names\SQL\ key (or you could get them from
HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\InstalledInstances (and
multi-valued string)).  The steps would probably be 1) look up the
instances in the InstalledInstances value, 2) for the instance you're
after get the reg branch from the HKLM\...\Instance
Names\SQL\/<InstanceName>/, 3) from the reg branch specified in that
value get the virtual server name from the
HKLM\...\/<InstanceBranch>/\Cluster\ClusterName value.  Something like
that (that's really just a guess).

--
*mike hodgson*
http://sqlnerd.blogspot.com

>Not sure exactly what the situation is, but could cluster.exe help?  It can
>list groups and resources.  What information IS known?  Do you know the node
[quoted text clipped - 42 lines]
>>  
>>    
melanie - 23 Feb 2006 16:20 GMT
Mike,

the registry keys and values you mentioned, that's exactly what I was looking for.

Thanks a lot
Melanie
 Ah, you want to enumerate SQL instances in order to connect to one?  To me that screams SMO (SQL Management Objects) but it's been some time since I played with SQL-DMO (SMO's previous incarnation) so I can't offer any authoritative comments.

 However, I'd be looking at the ManagedComputer class in the Microsoft.SqlServer.Management.Smo.Wmi namespace (in .NET 2.0).  I think given a ManagedComputer object, you can get a collection of the SQL instances on that computer with the ServerInstances property.  But I don't really know how you'd then get a connection string for one of those particular instances to actually connect to.  Maybe someone in the programming newsgroup can help.

 If you want to just poke through the registry (I wouldn't recommend it) I'd guess the virtual server name is stored in the ClusterName reg string value of the HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\Cluster\ key.  I think the instance names would then be stored under the HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL\ key (or you could get them from HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\InstalledInstances (and multi-valued string)).  The steps would probably be 1) look up the instances in the InstalledInstances value, 2) for the instance you're after get the reg branch from the HKLM\...\Instance Names\SQL\<InstanceName>, 3) from the reg branch specified in that value get the virtual server name from the HKLM\...\<InstanceBranch>\Cluster\ClusterName value.  Something like that (that's really just a guess).

 --
 mike hodgson
 http://sqlnerd.blogspot.com

 CShane wrote:
Not sure exactly what the situation is, but could cluster.exe help?  It can
list groups and resources.  What information IS known?  Do you know the node
name and are just looking for a virtual server name?  Do you want to list ALL
sql servers in the domain?  In short, what do you know and what are you
looking for?

Shane

"melanie" wrote:

 This works if I already have a connection to the sql server. But my problem is I have to find the name of the server I can connect to.

Any other solution?

Thanks
Melanie
 "Mike Hodgson" <e1minst3r@gmail.com> wrote in message news:%23iRtotmNGHA.2320@TK2MSFTNGP11.phx.gbl...
 The correct way to do this in SQL 2005 is the same as the correct way to do it in SQL 2000.  That is,

   SELECT SERVERPROPERTY('MachineName')

 No need to go messing about in the registry, simply ask SQL Server and it will tell you.  Check out the SERVERPROPERTY() function in BOL - it's packed full of useful goodies (so to is OBJECTPROPERTY(), INDEXPROPERTY() and the INFORMATION_SCHEMA schema).

 --
 mike hodgson
 http://sqlnerd.blogspot.com

 melanie wrote:
Hello,

Does anybody know how I can programmatically detect the name of the virtual
server if sql 2005 is running on a cluster?

In previous sql versions I looked up the following registry entries:

Default instance: "HKLM\\SOFTWARE\\Microsoft\\MSSQLServer\\Cluster" REG_SZ
"ClusterName"
Named instance: "HKLM\\SOFTWARE\\Microsoft\\Microsoft SQL
Server\\<InstanceName>\\Cluster" REG_SZ "ClusterName"

It seems as if this changed for sql 2005, right?

Thanks a lot
Melanie

 
   
Michael Hotek - 21 Feb 2006 23:23 GMT
AND...are you running AD on 2000 or 2003.  With 2003, everything will
register into AD.  With 2000, it won't.

Signature

Mike
http://www.solidqualitylearning.com
Disclaimer: This communication is an original work and represents my sole
views on the subject.  It does not represent the views of any other person
or entity either by inference or direct reference.

> Not sure exactly what the situation is, but could cluster.exe help?  It
> can
[quoted text clipped - 47 lines]
>> Thanks a lot
>> Melanie
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.