标签:io os ar 数据 art sp cti on c
曾经想过在循环读取数据的时候进行记录,但是那效率并没有直接在sql中用函数调用好
CREATE FUNCTION [dbo].[fnGetDistance](@LatBegin REAL, @LngBegin REAL, @LatEnd REAL, @LngEnd REAL) RETURNS FLOAT AS BEGIN --距离(米) DECLARE @Distance REAL DECLARE @EARTH_RADIUS REAL SET @EARTH_RADIUS = 6378137.0 --地球半径 DECLARE @RadLatBegin REAL,@RadLatEnd REAL,@RadLatDiff REAL,@RadLngDiff REAL SET @RadLatBegin = @LatBegin *PI()/180.0 SET @RadLatEnd = @LatEnd *PI()/180.0 SET @RadLatDiff = @RadLatBegin - @RadLatEnd SET @RadLngDiff = @LngBegin *PI()/180.0 - @LngEnd *PI()/180.0 SET @Distance = 2 *ASIN(SQRT(POWER(SIN(@RadLatDiff/2), 2)+COS(@RadLatBegin)*COS(@RadLatEnd)*POWER(SIN(@RadLngDiff/2), 2))) SET @Distance = @Distance * @EARTH_RADIUS RETURN @Distance END GO
只需要sql调用出来显示即可
标签:io os ar 数据 art sp cti on c
原文地址:http://www.cnblogs.com/code-change-word/p/3979993.html