Get the list of ZIP codes within a given radius from entered ZIP Code. The list will display city, state, county, population, number of businesses and the distance.
Re: How to create a search based on zip code and its radius ?
Oct 01, 2013 05:07 PM|jiveabillion|LINK
First, you need a zip code database that has GPS coordinates. This might work http://download.geonames.org/export/dump/US.zip
This one might work too http://federalgovernmentzipcodes.us/
They are both in txt files, so you'll need to use DTS or something to import them into your SQL database.
Second, you need a stored procedure that does some crazy math to calculate a radius on a sphere that will get all of the coordinates within a range from the coordinates of the zipcode you are searching around. You can find this online if you search. Here is one example http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sql-server-zipcode-latitude-longitude-pr
Then you join the results of that on your records that have the zip code in them and get your results.
There are web services that can do this for you, but they are usually not free or limit the number of searches per time period. Also, since the web service isn't in your database, you would have to call the web service and then pass the results to a query on your database. It is much faster to just do it in your own database. I've done it before and it isn't too hard to set it up.