Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author 
Topic 
roshanrise
Starting Member
1 Post 
Posted  20130422 : 09:24:42

I have created a function like the one below
ALTER FUNCTION fn_Calc (@Lat1 Float, @Lng1 Float, @Lat2 Float, @Lng2 Float) RETURNS Float AS BEGIN
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
RETURN @Distance
END
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?
Thanks, Roshan. N
Thanks, Roshan.N 

bandi
Master Smack Fu Yak Hacker
2242 Posts 

russell
Pyromaniyak
5072 Posts 
Posted  20130422 : 14:26:48

Make sure there are no divide by zero happening too 




