sqlIP转换
浏览量:2362
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()此函数为分割字符串,只识别.可把字符串的分隔符替换成.
上一篇:SQL数据生成实体类
下一篇:SQL半角全角查询