troubleshooting Question

Search for addresses within a given distance from my location

Avatar of Phil Catterall
Phil Catterall asked on
Microsoft SQL Server
5 Comments1 Solution358 ViewsLast Modified:
Here's an interesting one. I have address records which have a latitude and longitude - lets say a simple table with:
AddressId INT
Latitude decimal(10,6)
Longitude decimal(10,6)

I know my current position expressed also in degrees latitude and longitude (lets call them variables @Lat and @Long.

So can anyone assist me with some SQL to bring back those Id's which fall within a certain distance. Ideally records within a radius (r) of a circle where I am at the center, or a square at which I am the center if that is easier.
I did find a solution which uses a .Net CLR but I am restricted and not able to use a CLR.
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros