George, a good friend of mine created a blog post showing how you can do a SQL Server Zipcode Latitude/Longitude proximity distance search without using the geography data type. I searched the internet to see if anyone had something similar with the geography data type available in 2008 and could not find anything that showed some useful stuff. Yes there is a lot available with geometry and polygons but nothing I was looking for. George challenged me and I did the 2008 version.

There is nothing really complicated. if you run this
DECLARE @g geography;
DECLARE @h geography;
SET @h = geography::STGeomFromText('POINT(-77.36750 38.98390)', 4326);
SET @g = geography::STGeomFromText('POINT(-77.36160 38.85570)', 4326);
SELECT @g.STDistance(@h)/1609.344;

You will see that the distance in miles between those two points is 8.8490611480890067

In the end the code runs between 15 and 60 millisecond to get all the zipcodes within 20 miles of zipcode 10028, pretty impressive if you ask me


All the code including sample data for all the zip codes in the US can be found here


The reason I did not post it here is because George created the 2000 version so it would be weird if the 2008 version was somewhere else, but no worries I will have a post here tomorrow about "what do you wish you knew when you were starting?" Michelle Ufford  tagged me so look forward to that

Enter your email address to get free software's windows and virus removal tricks: SMS Alerts: Get news headlines on your mobile phone for freeMOBILE ALERTS

1 Comment

  1. Alexandru Said,

    Posted on Thursday, April 09, 2009

     

Post a Comment

Blog Widget by LinkWithin

Like us on FaceBooooooook

About author

Vishnu vardhan Reddy Boda is Tech Blogger and Software Engineer.

know more about vishnu

Recently Digged Indanam (fuel)

Get our posts as email

http://lh6.ggpht.com/_s0ANCL8E8sQ/SY7SyZ6WkXI/AAAAAAAAAhg/-qr1lvldUdA/Newspaper_Feed_128x128newcopy-1.png Sign up for our daily email newsletter

Dont miss any thing Enter your email address:

SMS Alerts: Get news headlines on your mobile phone for free