SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

Calculate Distance in Miles from Latitude and Longitude

By RBarry Young, 2009/02/17

Total article views: 3039 | Views in the last 30 days: 177

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.)

By RBarry Young, 2009/02/17

Total article views: 3039 | Views in the last 30 days: 177
Your response
 
 
Related tags

function     Spherical coordinates    
Geometry     T-SQL    
GPS     Zip codes    
 
 
Contribute

Free registration required...

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Login (existing users)

Login

Email:   Password:   Remember me: Forgotten your password?

Register (new users)

Register

Email:   Password:
Confirm:

Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

Steve Jones
Editor, SQLServerCentral.com