我在 SQL Server 2012 ACOS 函数中遇到了这个错误:
declare @lat1 decimal(12,10), @lon1 decimal(12,10), @lat2 decimal(12,10), @lon2 decimal(12,10)
declare @dist float
select @lat1=51.1790825000, @lon1= 4.1590020000, @lat2= 51.1790825000, @lon2= 4.1590020000
set @dist = SIN(RADIANS(@lat1)) * SIN(RADIANS(@lat2)) + COS(RADIANS(@lat1)) * COS(RADIANS(@lat2)) * COS(RADIANS(@lon1 - @lon2))
print @dist
print ACOS(1)
print ACOS(@dist)
最后一个打印函数给出“发生了无效的浮点操作”。这在 SQL Server 2008 中运行良好
弗拉德