Monday, 21 December 2020

Calculate distance between two latitude longitude points using SQL Server

 /////////// Sql query


DECLARE @Lat decimal(18,4) = 17.491716000
,@Long decimal(18,4) = 76.514721000
,@Lat_2 decimal(18,4) = 17.341667000
,@Long_2 decimal(18,4) = 76.596667000
, @Location decimal(18,4) 
 
SET @Location = SQRT(POWER(69.1 * ( @Lat_2 - @Lat),2) + POWER(69.1 * ( @Long - @Long_2)* COS(@Lat_2 / 57.3), 2)) 
select @Location


/////////// Result

11.6913


No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...