I am trying to return matching zip codes as a table, so I can use it with 'Where zipCode IN(...) statement.
create function dbo.zipSearch(@zip varchar(12), @mile int)
returns table
as
begin
declare @ns float = @mile * 0.00569;
declare @ew float = @mile * 0.01629;
declare @ltt float, @lng float;
Select @ltt = latitude, @lng = longitude From ZipCode Where ZIP = @zip;
Select ZIP From zipcode Where latitude >= @ltt - @ns and latitude <= @ltt + @ns and longitude >= @lng - @ew and longitude <= @lng + @ew;
return
end
What would be the alternative if this is not possible?