Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 hostname

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2008-06-18 : 04:12:16
Hi,

Question:
How do I get the hostname from the instance name please?

My present design at present is something as follows:

We have several sql server 2005 machines
i.e.
ServerSQLA, ServerSQLB, etc....

Each machine may have one or more instances,
i.e.
ServerSQLA\instace1
ServerSQLA\instace2, etc...

The server name in this case is ServerSQLA

Instance naming and node convention is different for clusters

i.e.
C_ServerSQLA\instance1
C_ServerSQLA\instance2

on the node(s):
N_ServerSQLA or N_ServerSQLB


Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-18 : 04:13:23
Have you tried @@SERVERNAME ?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2008-06-18 : 04:17:52
No, But will this give the correct hostname based on the instance?
Thanks
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-18 : 04:25:33
You have to try on your cluster.


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-18 : 04:27:06
Or try the SERVERPROPERTY function?
SELECT	SERVERPROPERTY('InstanceName'),
SERVERPROPERTY('MachineName'),
SERVERPROPERTY('ServerName')



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2008-06-18 : 05:07:35
I will try this soon and come back to you.
Thanks
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2008-06-18 : 06:21:43
None of these appear to give the actual windows hostname of the active node for a clustered instance.
Not sure if this query is useful:
SELECT * FROM fn_virtualservernodes()

Thanks
Go to Top of Page
   

- Advertisement -