Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL 2008 using Geography, Lat and Long

Author  Topic 

BigMeat
Yak Posting Veteran

56 Posts

Posted - 2009-02-12 : 13:31:33
Hi

I have a .Net 3.5 web app which uses SQL Express 2008. I want to create a list of customers that are near the user. I have identified the location of the user as I request their postcode, from this I have attained their Latitude and Longitude from a lookup table.

I also have a table of customers, each customer has its own latitude and longitude. I would like to create a query that will allow me to say find customers within X miles of the user.

Im not sure how do this, do i need to save the Latitude and Longitude fields into a field Geography field inorder to do the calculation.

Also how do I say find within 2 miles of Users Latitude and Longitude?

Any help would be much appreciated

Many thanks in advance

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-02-12 : 14:19:58
Just search in this forum. I remember seeing the exact code for this scenario.
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-02-12 : 15:15:17
here it is, http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81360&SearchTerms=haversine
Go to Top of Page
   

- Advertisement -