小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

SQL中與IP相關(guān)的常見問題

 qzg589 2005-09-09

SQL中與IP相關(guān)的常見問題

[日期:2005-07-08] 來源:CSDN  作者: [字體: ]

1:得到客戶端的IP地址
/************* IP  **************/
declare @ip varchar(20),@hst varchar(20),@sql varchar(100)
declare @str varchar(100)
set @str=‘PING ‘+Host_Name()
create table #tmp(aa varchar(200))
insert #tmp exec master..xp_cmdshell @str
select top 1 @ip = replace(left(aa,charindex(‘:‘,aa)-1),‘Reply from ‘,‘‘)
   from #tmp where aa like ‘reply from %:%‘
drop table #tmp
select @ip


2:得到網(wǎng)卡的物理地址
create table #tb(re varchar(255))
insert into #tb exec master..xp_cmdshell ‘ipconfig /all‘

select 網(wǎng)卡物理地址=substring(re,charindex(‘:‘,re)+1,255) from #tb where re like ‘%Physical Address. . . . . . . . . :%‘

drop table #tb

3:    將IP地址段轉(zhuǎn)成每三位用點號分開    
create function getIP(@a varchar(15))
returns varchar(15)
As
begin
declare @s varchar(15)
set @s = ‘‘
while charindex(‘.‘,@a) > 0
begin
 set @s = @s + right(‘000‘ + left(@a,charindex(‘.‘,@a)),4)
 set @a = right(@a,len(@a)-charindex(‘.‘,@a))
end
set @s = @s + right(‘000‘ + @a,3)
return @s
end

/*
Select dbo.getIP(‘202.1.110.2‘)
---------------
202.001.110.002

(所影響的行數(shù)為 1 行)
*/
--drop function getIP

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多