我创建了一个类似下面的函数
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
我正在使用上述函数来更新表中的列,如下所示:
Update test
set calc = dbo.fn_Calc(cast(Lat as float), cast(Long as float), dblLat, dblLong)
在运行上述查询时,我得到了错误。
“发生域错误。”
什么可能导致此错误?