Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm looking to store GPS co-ordinates in an MS SQL Server DB for location matching of users with GPS-enabled mobile phones.

I've read about STDistance on MSDN, but it only appears to exist in SQL Server 2008 (& later) along with the geometry and geography field types.

However, I'll need to support older versions of SQL Server as well (at least 2005).
What's the best way of storing GPS co-ordinates and calculating distances between 2 GPS locations in SQL Server 2005?

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

GPS co-ordinates are just latitude and longitude - if you have to support SQL 2005, then store them as numbers to your required precision.

To calculate the distance, you can implement the Haversine formula

share|improve this answer
    
Looking at Decimal and Numeric on MSDN and examples of GPS co-ordimnates, decimal(18,12) would be suitable? –  SteB Nov 21 '12 at 9:20
    
Numeric is the same as decimal. It depends how precise you need to be, but it would be a good starting point. –  podiluska Nov 21 '12 at 9:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.