snippetsqlMinor
How do I store spatial coordinates in SQL Server 2005
Viewed 0 times
coordinatessqlstore2005howserverspatial
Problem
I'm looking to store GPS co-ordinates in an SQL Server 2005 for location matching of users with GPS-enabled mobile phones. I've read about
What's the best way of storing GPS co-ordinates and calculating distances between 2 GPS locations in SQL Server 2005?
STDistance on MSDN, but it only appears to exist in SQL Server 2008 (& later) along with the geometry and geography field types. 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?
Solution
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
To calculate the distance, you can implement the Haversine formula
Context
StackExchange Database Administrators Q#29034, answer score: 3
Revisions (0)
No revisions yet.