Guys/Gal,
I need help, I am going nuts... I am trying to find a query which will retrieve the IP-Address of the local host... It seems that SQL does not store this anywhere!!!
Any help would be welcome...
Thank You...
See, if this helps:
set nocount ondeclare @ip varchar(255), @cmd varchar(100) set @cmd = 'ping ' + HOST_NAME() create table #temptb (grabfield varchar(255)) insert into #temptb exec master.dbo.xp_cmdshell @cmd select @ip = substring(grabfield, charindex('[',grabfield)+1, charindex(']',grabfield)-charindex('[',grabfield)-1) from #temptb where left(grabfield,7) = 'Pinging' print @ip drop table #temptbset nocount off
Nice one Frank
I was using xp_cmdshell 'ipconfig' (which is a bit faster) to check the general ip settings but 'ping ' + HOST_NAME() is perhaps easier to hack.
Thanks! There is more than one way to skin that cat. However, native T-SQL support for this is on my personal wishlist.
Thanks everyone, it works like a charm....
Hm, why only does HOST_NAME() return my workstation name?
select host_name()
-------------------- WST3XXXXXX
(1 row(s) affected)