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