Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Calculate Distance in Miles from Latitude and Longitude

By RBarry Young, 2011/04/15

With the advent of GPS and other widely available global location data, there is an increasing need to be able to accurately calculate the distance between two points over the earth's surface, from latitudes and longitudes. This SQL function does just that ,returning the distance in miles.

this function has several other advantages as well, first, it is very accurate, usually 4 to 5 decimal places. and secondly, it is much faster than most other, less accurate, algorithims. (if even more speed is needed, then include this calculation in-line in the body of your query.)

Total article views: 5317 | Views in the last 30 days: 14
 
Related Articles
FORUM

count of rows in table is not accurate.

count of rows in table is not accurate.

FORUM

How do I get accurate percentages?

Problem achieving accurate percentage figures after rounding

ARTICLE

Searching Syscomments Accurately

As a SQL Server DBA you should know that your code is stored in syscomments by default. While most D...

FORUM

Accurate datediff by years

I tried performing datediff on two strings converted into datetimes and found that it simply subtra...

FORUM

Searching Syscomments Accurately

Comments posted here are about the content posted at http://www.sqlservercentral.com/columnists/rca...

Tags
function    
geometry    
gps    
spherical coordinates    
t-sql    
zip codes    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones