0

I've got locations stored in the database(SQL-server), their location is declared as geography and another column declaring it's radius.
Giving a geography(or longitude/latitude) as parameter I would like to get the locations with a radius intersecting the parameters radius (a constant value) in return.

Any information on how to solve this is appreciated.

Patrik
  • 13
  • 2
  • possible duplicate of [Finding a geography point within a range of another - SQL Server](http://stackoverflow.com/questions/8384893/finding-a-geography-point-within-a-range-of-another-sql-server) – jpw Feb 18 '15 at 09:45

1 Answers1

0

First note that the radii intercept each other if and only if the sum of the radii is greater than the distance between the two points.

I'm not that familiar with the syntax but you want something like this - I'm making use of the STDistance function of the Transact SQL geography data type.

SELECT * FROM TABLE
WHERE TABLE.RADIUS + @radius >= @geog.STDistance(TABLE.GEOGRAPHY);
Dilitante
  • 148
  • 9