Skip to content Skip to sidebar Skip to footer

Sql Spatial Join

I have 2 tables one with points as geographies and other with polygons as geographies. I am able to find which polygon a single point falls(from the point table) by the following q

Solution 1:

This should work:

SELECT 
    polyTable.[PolygonID]
,   pointTable.[PointID]
FROM 
[PolygonTable_Name] polyTable WITH(INDEX([SPATIAL_INDEX_NAME]))
INNERJOIN 
[PointTabl_Name] pointTable
ON
polyTable.Geog.STIntersects(pointTable.Geog) =1

I have added an index hint " WITH(INDEX(...)) " as this will speed up the query.

Post a Comment for "Sql Spatial Join"