I have coordinates in my database stored as (55.573012889640765, 9.72362365248182). I want to make a function that will get this value and put them on @latitude = 55.573012889640765 and @long=9.72362365248182.
So practically the function gets the coordinates and returns me the two points separately . I want to get this so I can calculate the distance between two points later on with a function like this one:
CREATE FUNCTION dbo.fnCalcDistanceKM(@lat1 FLOAT, @lon1 FLOAT, @lat2 FLOAT, @lon2 FLOAT)
RETURNS FLOAT
AS
BEGIN
RETURN ACOS(SIN(PI()*@lat1/180.0)*SIN(PI()*@lat2/180.0)+COS(PI()*@lat1/180.0)*COS(PI()*@lat2/180.0)*COS(PI()*@lon2/180.0-PI()*@lon1/180.0))*6371
END
As you see this function requires the points to be separated and in my database I have them as one . Can you please le me know how to divide the parts or modify the above function to fit my code.
Thank you in advance