Search code examples
c#sql-servergeolocationgeo

How to find area around my current point lat and long


I have a point with latitude and longitude as (current place). In my Database, I have many points (lat & long) which show me stores (for example). I need a SQL Server query to get stores which are near my current place with 5 Kilometers distance.


Solution

  • Use STDistance method:

    SELECT * FROM dbo.MyTable WHERE Location.STDistance(@CurrentPlace) <= 5000;