geography.STWithin
spatial predicate STWithin
What changes
- Input
- one or two spatial instances
- Output or change
- bit
- Return type
- SQL Server return type: bit CLR return type: SqlBoolean
Syntax at a glance
.STWithin ( other_geography )
Work example
Use geography.STWithin to test whether this shape lies within another.
Check argument direction and decide how boundary contact counts. Confirm both values use the same SRID before comparing or combining them.
Check your work The point is inside the polygon, so the point is within the area.
Practice SQL
Open in SQL FlowOpen the SQL for a walkthrough. Run the example in SQL Server to check its result.
SELECT p.shape.STWithin(aoi.shape) AS point_is_within FROM (VALUES (geography::Point(47.654, -122.353, 4326))) AS p(shape) CROSS JOIN (VALUES (geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326))) AS aoi(shape);
Open Microsoft Learn for full syntax, permissions, and details for your version.