SQL中與IP相關的常見問題

2021-04-06 15:55:46 字數 808 閱讀 1312

2:得到網絡卡的實體地址

create table #tb(re varchar(255))

insert into #tb exec master..xp_cmdshell 'ipconfig /all'

select 網絡卡實體地址=substring(re,charindex(':',re)+1,255) from #tb where re like '%physical address. . . . . . . . . :%'

drop table #tb

3: 將ip位址段轉成每三位用點號分開

create function getip(@a varchar(15))

returns varchar(15)

asbegin

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))

endset @s = @s + right('000' + @a,3)

return @s

end

/*select dbo.getip('202.1.110.2')

---------------

202.001.110.002

(所影響的行數為 1 行)

*/--drop function getip

C 中SQL 常見問題

user為sql關鍵字,不能作為表名用在sql server的表建立中 sql server建表 create table userinfo num int identity 1,1 primary key,mailbox varchar 50 name varchar 20 pwd varchar...

Sql 常見問題

select from orders left join orderlines on orderlines.orderid orders.id where orders.id 12345select from orders left join orderlines on orderlines.ord...

IP路由常見問題整理

1 常見的路由協議優先順序 direct 0 ospf 10 is is 15 static 60 rip 100 ospf ase 150 bgp 255 2 路由表選路順序 路由表中包含了路由器可以到達的目的網路,目的網路在路由表中不存在的資料報會被丟棄 1 最長掩碼匹配原則 精確 2 路由優先...