请问如何得到当前连接的spid对应的ip地址?多谢

qinqindodo 2004-04-13 09:32:43
请问如何得到当前连接的spid对应的ip地址?多谢
...全文
225 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
qinqindodo 2004-04-13
  • 打赏
  • 举报
回复
多谢指教,结贴
zjcxc 2004-04-13
  • 打赏
  • 举报
回复
create table #t(id int identity(1,1),re varchar(8000))

declare @s varchar(1000)
select @s='ping '+hostname+' -a -n 1 -l 1'
from master..sysprocesses
where spid=54 --54是spid
insert #t exec master..xp_cmdshell @s
select ip=substring(re,12,charindex(': bytes=1',re)-12)
from #t where id=4

drop table #t

qinqindodo 2004-04-13
  • 打赏
  • 举报
回复
此外 master..sysprocesses 和 master..xp_cmdshell 是什么意思呢?
qinqindodo 2004-04-13
  • 打赏
  • 举报
回复
但是如何从结果中取得ip地址呢?〉对不起,我很菜

Pinging YT-DOMINO [192.168.0.10] with 1 bytes of data:

Reply from 192.168.0.10: bytes=1 time<10ms TTL=128

Ping statistics for 192.168.0.10:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
NULL
qinqindodo 2004-04-13
  • 打赏
  • 举报
回复
高手,多谢赐教
zjcxc 2004-04-13
  • 打赏
  • 举报
回复
declare @s varchar(1000)
select @s='ping '+hostname+' -a -n 1 -l 1'
from master..sysprocesses
where spid=54 --54是spid
exec master..xp_cmdshell @s

22,206

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧