Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you get Sql Server to return its IP Address 2

Status
Not open for further replies.

mwolf00

Programmer
Nov 5, 2001
4,177
US
I'm trying to connect to a server via VPN and I don't know its IP address only its server name. I can query the server via an ASP page that I wrote. Is there a query that will return the IP address of the server?

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
declare @hostName varchar(666)
select @hostName = host_name()

CREATE TABLE #Results(Results VARCHAR(4000))

DECLARE @Commandstring VARCHAR(900)

SET @Commandstring = 'ping ' + @hostName

INSERT INTO #Results

EXEC master..xp_cmdshell @Commandstring

Select DISTINCT SUBSTRING(Results,12,CHARINDEX(':',Results)-12) AS HostIpAdress from #Results

Where Results LIKE 'Reply From%'

DROP TABLE #Results


Denis The SQL Menace
SQL blog:
Personal Blog:
 
Dennis -

Thank you for your assistance. All I can do is execute stand alone queries via ASP in a line that says

set rs = cn.execute(sql)

Is there still a way to do this?



Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
I'm not sure - I'm trying that. Right now

SELECT host_name()

returns the name of the web server not the name of the DB Server.

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top