In Sql server 2008 it was very simple for me to obtain the distance between two latitude and longitude points, but now I am using Sql server 2005 and the data type geography
does not seem to exist... I did this:
DECLARE @source geography = 'POINT(0 51.5)'
DECLARE @target geography = 'POINT(-3 56)'
SELECT @source.STDistance(@target)
Unfortunately this doesn't work for me on Sql server 2005
Any idea or type of data to help me with this, if it doesn't exist, will I have to do the calculation, let's say "manual"?
In SQL 2005, there is no geography data type . If you take into account the actual shape of the earth, this becomes tricky (plus there are many reference systems you may want to interpret coordinates in.
Simplifying everything to the fact that the earth was a sphere (which it is not, and therefore the result if you implement this answer will only be an approximation of reality), you could do something like this, since in the end the calculation is nothing more than a bit of trigonometry:
With these functions defined, you would get this result: