Last active
August 29, 2015 14:19
-
-
Save NPS-ARCN-CAKN/5ef102a7e0c2672cc3ab to your computer and use it in GitHub Desktop.
SQL: Select points that fall within a polygon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- SQL Server 2008R2, there are better functions in later versions of Sql Server such as STContains() | |
SELECT Animals.GroupNumber | |
FROM LegacyUnits INNER JOIN | |
Animals ON LegacyUnits.PolygonFeature.STIntersects(Animals.Location) = 1 | |
-- Here is an UPDATE query example: | |
UPDATE Animals | |
SET Unit = LegacyUnits.LegacyUnitID | |
FROM LegacyUnits INNER JOIN | |
Animals ON LegacyUnits.PolygonFeature.STIntersects(Animals.Location) = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment