Hello guys,
I'm trying to get the points inside a polygon with an spatial query, the thing is that the points and the polygon are in the same SQL Table, I'm attaching a picture with the result of a Select Query (image attached) where you can see that the last 3 records are the polygons that contains points.
I've tried this with one point but it won't work because I need a list with the names of the polygons and the points inside of it in a spatial query.
DECLARE @POI geography;
DECLARE @POLYGON geography;
SET @POI = (SELECT TOP 1 GEO FROM POI WHERE LAYERID <> 1026);
SET @POLYGON = (SELECT TOP 1 GEO FROM POI WHERE LAYERID = 1026);
SELECT @POLYGON.STContains(@POI);
I'm trying to get the points inside a polygon with an spatial query, the thing is that the points and the polygon are in the same SQL Table, I'm attaching a picture with the result of a Select Query (image attached) where you can see that the last 3 records are the polygons that contains points.
I've tried this with one point but it won't work because I need a list with the names of the polygons and the points inside of it in a spatial query.
DECLARE @POI geography;
DECLARE @POLYGON geography;
SET @POI = (SELECT TOP 1 GEO FROM POI WHERE LAYERID <> 1026);
SET @POLYGON = (SELECT TOP 1 GEO FROM POI WHERE LAYERID = 1026);
SELECT @POLYGON.STContains(@POI);