Posted - 04/22/2013 : 09:24:42
| I have created a function like the one below
ALTER FUNCTION fn_Calc
Declare @x as Float
Declare @y as Float
Declare @Distance as Float
Select @x = (SIN(RADIANS(@Lat1)) * SIN(RADIANS(@Lat2)) + COS(RADIANS(@Lat1)) * COS(RADIANS(@Lat2)) * COS(ABS((RADIANS(@Lng2)) - (RADIANS(@Lng1)))))
Select @y = ATAN((SQRT(1-(POWER(@x,2))) / @x))
Select @Distance = (1.852 * 60.0 * ((@y / PI()) * 180)) / 1.609344
I am using the above function to update a column in a table like below:
Update test set calc = dbo.fn_Calc( cast(Lat as float), cast(Long as float), dblLat, dblLong)
While running the above query I got the error.
"A domain error occured."
What can be causing this error?
Edited by - roshanrise on 04/22/2013 09:25:33