December 3, 2003 at 4:58 am
Is there any way to get the IP address of the machine conneted to SQL Server? I am not intrested in the machine name.
Regards,
Sachin Dedhia
December 3, 2003 at 5:11 am
AFAIK, from within SQL Server you're pretty much out of luck.
Server IP you should get with
declare @ip varchar(255)
create table #temptb (grabfield varchar(255))
insert into #temptb exec master.dbo.xp_cmdshell "ipconfig"
select @ip = ltrim(right(grabfield,len(grabfield)-charindex(':',grabfield)))
from #temptb where charindex('IP Address', grabfield) > 0
print @ip
drop table #temptb
It might work calling command line tools like http://www.sysinternals.com
Have you searched this site?
Frank
Edited by - Frank kalis on 12/03/2003 05:11:37 AM
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
December 3, 2003 at 5:35 am
Thanks Frank, I did feel I was pretty much out of luck while posting this 🙁
Haven't come across this site. Seems to be a good one 🙂 Running out of time...Will do it sometime later.
Hope better luck next time
Sachin
😉
Regards,
Sachin Dedhia
December 3, 2003 at 10:21 pm
You can execute netstat -na in a command window on the server. The IP addresses next to the ServerIP:1433 will show you who (IP) is trying to connect to the SQL server.
Stanislav Petkov
Stanislav Petkov
December 4, 2003 at 6:50 am
Following on from Fank's suggestion, use ping instead
declare @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 #temptb
Far away is close at hand in the images of elsewhere.
Anon.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply