找到这个 #lat为纬度, lng为经度, 一定不要弄错
declare @
lon1 float;
declare @
lat1 float;
declare @
lon2 float;
declare @
lat2 float;
set @
lon1=116.3899;
set @
lat1=39.91578;
set @
lon2=116.3904;
set @
lat2=39.91576;
select (2*ATAN2(SQRT(SIN((@lat1-@lat2)*PI()/180/2)
*SIN((@lat1-@lat2)*PI()/180/2)+
COS(@lat2*PI()/180)*COS(@lat1*PI()/180)
*SIN((@lon1-@lon2)*PI()/180/2)
*SIN((@lon1-@lon2)*PI()/180/2)),
SQRT(1-SIN((@lat1-@lat2)*PI()/180/2)
*SIN((@lat1-@lat2)*PI()/180/2)
+COS(@lat2*PI()/180)*COS(@lat1*PI()/180)
*SIN((@lon1-@lon2)*PI()/180/2)
*SIN((@lon1-@lon2)*PI()/180/2))))*6378140;
@
fangzhzh