sqlIP轉(zhuǎn)換
瀏覽量:2476
CRM定制
if OBJECT_ID('ufn_getip') is not null
drop function dbo.ufn_getip;
go
create function dbo.ufn_getip (@ip varchar(15))
returns bigint as
begin
return cast(PARSENAME(@ip,1) as bigint)+cast(PARSENAME(@ip,2) as bigint)*POWER(2,8)+
cast(PARSENAME(@ip,3) as bigint)*POWER(2,16)+cast(PARSENAME(@ip,4) as bigint)*POWER(2,24);
end
parsename()此函數(shù)為分割字符串,只識(shí)別.可把字符串的分隔符替換成.
下一篇:SQL半角全角查詢

