I send these paramaters my script : Latitude : 41.0186 Longitude : 28.964701 (it is sample). i want to find nearest location\'s name. how to do this? (query\'s where code\'s mus
declare @latitude float, @longitude float
select @latitude = 41.0186, @longitude = 28.964701
SELECT [Name] --, other columns
,Distance
from
(
select
[Name] --, other columns
,( 3959 * acos( cos( radians(@latitude) ) * cos( radians( [Lattitude] ) ) * cos( radians( [Longitude] )
- radians(@longitude) ) + sin( radians(@latitude) ) * sin( radians( [Lattitude] ) ) ) )
AS Distance FROM [dbo].[Location]
) as x
where Distance < 5
order by distance