爱心技术专栏专题

获取该进程所在客户端的ip地址

摘录:sql server 来源:sql server 加入时间:2006年07月17日
摘要:
获取该进程所在客户端的ip地址

create PROCEDURE dbo.SP_SPIDtoIP @SPID int AS -- SPID to MAC -- lj DECLARE @MAC as varchar(12) SELECT @MAC = NET_ADDRESS FROM master..sysprocesses WHERE SPID = @SPID -- MAC to IP DECLARE @MACDispla…

转载:转载请保留本信息,本文来自
http://www.51dibs.com
/html/2006/article/info14/a_80bbc2ecaf8d8ddb.htm

获取该进程所在客户端的ip地址

站点:爱心种子小博士 关键字:获取该进程所在客户端的ip地址
获取该进程所在客户端的ip地址
create PROCEDURE dbo.SP_SPIDtoIP @SPID int AS -- SPID to MAC -- lj DECLARE @MAC as varchar(12) SELECT @MAC = NET_ADDRESS FROM master..sysprocesses WHERE SPID = @SPID -- MAC to IP DECLARE @MACDisplay as varchar(18) DECLARE @IP as varchar(15) CREATE TABLE #temp (OUTPUT varchar(255) null) SET NOCOUNT ON INSERT INTO #temp EXEC master..xp_cmdshell arp -a if @@error begin RAISERROR (The level for job_id:%d should be between %d and %d., 16, 1) --ROLLBACK TRANSACTION end SELECT @MACDisplay = LEFT(@MAC, 2) + - + SUBSTRING(@MAC, 3, 2) + - + SUBSTRING(@MAC, 5, 2) + - + SUBSTRING(@MAC, 7, 2) + - + SUBSTRING(@MAC, 9, 2) + - + SUBSTRING(@MAC, 11, 2)SELECT @IP = SUBSTRING(output, 3, 15) FROM #temp WHERE output LIKE % + @MACDisplay + % -- Resolve the IP --DECLARE @CMD as varchar(100) --select @CMD = master..xp_cmdshell "ping -a + @IP + " --exec (@CMD) DROP TABLE #temp SET NOCOUNT OFF GO

客户服务中心信箱:[email protected] [email protected] 网站地图

声明

合作伙伴: