December 6, 2005 at 12:03 pm
Hi all,
We were trying to write a stored proc to mail whenever a server gets restarted. The problem we are facing right now is with getting the physical node name. We have used @@ServerName to get the virtual node name, and HOST_NAME() to get the physical node name. But, HOST_NAME() returns nothing for some reason (???!!!???). The same script works fine from QA. The stored Proc is configured to run at start up. It is a clustered environment.
We have even tried to use the following code but were unsuccessful here too.
INSERT INTO ##ClusterNode
EXEC XP_CMDSHELL 'cluster.exe /CLUSTER:ClusterName GROUP'
Thanks in advance..
Sirish
December 7, 2005 at 4:52 am
Sirish,
Something else you could try is
INSERT INTO ##ClusterNode
EXEC XP_CMDSHELL 'SET COMPUTERNAME'
... then substring the result if you get anything sensible back.
December 7, 2005 at 12:11 pm
SET COMPUTERNAME returns the virtual server's NBNAME, which is the same no matter what physical node it's running on.
Try this:
create table #foo (
id tinyint identity(1,1),
txt varchar(255))
Insert #foo (txt)
exec master.dbo.xp_cmdshell 'ping localhost -n 1'
select substring(txt,9,charindex('[',txt)-10) from #foo where id=2
drop table #foo
This should return the FQDN of the physical server on which your virtual server is running.
jg
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy