SQL Flow Field Guide

geography.STContains

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

spatial predicate STContains

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

.STContains ( other_geography )

Work example

Use geography.STContains to test whether one shape contains another.

Check argument direction, matching SRIDs, and boundary behavior. Confirm both values use the same SRID before comparing or combining them.

Check your work The point lies inside the polygon, so the polygon contains the point.

Practice SQL

Open in SQL Flow

Open the SQL for a walkthrough. Run the example in SQL Server to check its result.

SELECT aoi.shape.STContains(p.shape) AS contains_point FROM (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) CROSS JOIN (VALUES (geography::Point(47.654, -122.353, 4326))) AS p(shape);

Open Microsoft Learn for full syntax, permissions, and details for your version.