سلام.
بهترین کار اینه:
یک تابع بنویسید که فرمت IP شما رو تبدیل کنه به باینری متناظرش.
create function IP2Decimal(@IP varchar(15))
returns decimal
as
begin
declare @IP_1 decimal
declare @IP_2 decimal
declare @IP_3 decimal
declare @IP_4 decimal
set @IP_1 =substring(@IP, 1,CHARINDEX('.', @IP, 1)-1)
set @IP =substring(@IP,CHARINDEX('.', @IP, 1)+1,LEN(@IP))
set @IP_2 =substring(@IP, 1,CHARINDEX('.', @IP, 1)-1)
set @IP =substring(@IP,CHARINDEX('.', @IP, 1)+1,LEN(@IP))
set @IP_3 =substring(@IP, 1,CHARINDEX('.', @IP, 1)-1)
set @IP_4 =substring(@IP,CHARINDEX('.', @IP, 1)+1,LEN(@IP))
return @IP_1 * 256 * 256 * 256 + @IP_2 * 256 * 256 + @IP_3 * 256 + @IP_4
end
و در فیلترتون به راحتی Between می گیرید!
where dbo.IP2Decimal(Field)between dbo.IP2Decimal(Field1)and dbo.IP2Decimal(Field2) -- so easy
مثال:
print dbo.IP2Decimal('192.168.0.21') -- wow