For find distance between two latitude and longitude in SQL Server, we can use below mentioned query. This query calculate the distance in miles.
  1. DECLARE @sourceLatitude FLOAT = 28.58;
  2. DECLARE @sourceLongitude FLOAT = 77.329;
  3. DECLARE @destinationLatitude FLOAT = 27.05;
  4. DECLARE @destinationLongitude FLOAT = 78.001;
  5. DECLARE @Location FLOAT
  6. SET @Location = SQRT(POWER(69.1 * ( @destinationLatitude - @sourceLatitude),
  7. 2) + POWER(69.1 * ( @sourceLongitude
  8. - @destinationLongitude )
  9. * COS(@destinationLatitude / 57.3), 2))
  10. PRINT @Location