USE [UILogDB]
GO
/****** Object: UserDefinedFunction [dbo].[ipStringToBigInt] Script Date: 11/09/2011 09:47:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[ipStringToBigInt] ( @ip CHAR(15) )
RETURNS bigint
AS
BEGIN
DECLARE @rv bigint, @o1 bigint, @o2 INT, @o3 INT, @o4 INT
if (isnumeric(replace(@ip,'.',''))<>0)
begin
SELECT @o1 = CONVERT(INT, PARSENAME(@ip, 4)), @o2 = CONVERT(INT, PARSENAME(@ip, 3)), @o3 = CONVERT(INT, PARSENAME(@ip, 2)), @o4 = CONVERT(INT, PARSENAME(@ip, 1))
IF (@o1 BETWEEN 0 AND 255) AND (@o2 BETWEEN 0 AND 255) AND (@o3 BETWEEN 0 AND 255) AND (@o4 BETWEEN 0 AND 255)
BEGIN
SET @rv = (@o1 * 16777216) + (@o2 * 65536) + (@o3 * 256) + (@o4)
END
ELSE
SET @rv = 0 RETURN @rv
end
else
SET @rv = 0 RETURN @rv
END
IP Char to Int
最新推荐文章于 2021-05-20 03:43:21 发布