当前位置:Gxlcms > 数据库问题 > Sqlserver 计算两坐标距离函数

Sqlserver 计算两坐标距离函数

时间:2021-07-01 10:21:17 帮助过:44人阅读

exists (select * from dbo.sysobjects where id = object_id(NUF_ETL_GetDistance) and xtype in (NFN, NIF, NTF)) drop function UF_ETL_GetDistance GO CREATE FUNCTION UF_ETL_GetDistance ( @sLng DECIMAL(12,6), @sLat DECIMAL(12,6), @eLng DECIMAL(12,6), @eLat DECIMAL(12,6) ) RETURNS DECIMAL(12,4) AS BEGIN DECLARE @result DECIMAL(12,4) SELECT @result = 6378137.0*ACOS(SIN(@sLat/180*PI())*SIN(@eLat/180*PI())+COS(@sLat/180*PI())*COS(@eLat/180*PI())*COS((@sLng-@eLng)/180*PI())) RETURN @result/1000 END go

 

Sqlserver 计算两坐标距离函数

标签:cts   col   type   exists   nbsp   drop   cos   etl   distance   

人气教程排行