How do I find points that are NOT within a list of polygons using MS SQL?

المشرف العام

Administrator
طاقم الإدارة
I have a table of points, and and a table of polygons. I have managed to build queries (MS SQL) to get the containing polygon for a given point, as well as listing all the points within a specified polygon, but I cannot work out how to find all points that are not within any polygon.

The following query lists all points with the containing polygon. My initial thought was to just look points that are not contained (i.e. STContains() 1), but this returns all points too, seem there are always polygons that do not contain a given point.

SELECT points.name, polygons.name FROM points CROSS JOIN polygons WHERE (polygons.shape.STContains(points.shape) = 1) How do I find those points that are not within any polygons?



أكثر...
 
أعلى