Sqlserver 计算两坐标距离函数
发布时间:2020-12-12 14:20:10 所属栏目:MsSql教程 来源:网络整理
导读:mark if exists ( select * from dbo.sysobjects where id = object_id (N ‘ UF_ETL_GetDistance ‘ ) and xtype in (N ‘ FN ‘ ,N ‘ IF ‘ ,N ‘ TF ‘ )) drop function UF_ETL_GetDistance GO CREATE FUNCTION UF_ETL_GetDistance( @sLng DECIMAL ( 12
mark if exists (select * from dbo.sysobjects where id = object_id(N‘UF_ETL_GetDistance‘) and xtype in (N‘FN‘,N‘IF‘,N‘TF‘)) drop function UF_ETL_GetDistance GO CREATE FUNCTION UF_ETL_GetDistance ( @sLng DECIMAL(12,6),@sLat DECIMAL(12,@eLng DECIMAL(12,@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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |