SQL Flow Field Guide

geometry.STExteriorRing

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

spatial method STExteriorRing (instance.STExteriorRing(...))

What changes

Input
spatial instance (and arguments)
Output or change
geometry
Return type
SQL Server return type: geometry CLR return type: SqlGeometry Open Geospatial Consortium (OGC) type: LineString

Syntax at a glance

.STExteriorRing ( )

Work example

Use geometry.STExteriorRing to read a polygon exterior ring.

Check that the source is a polygon and inspect the returned line. Keep the geometry type and SRID in the review.

Check your work The result is the 10-by-10 exterior ring. The interior hole is not included.

Practice SQL

Open in SQL Flow

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

-- Planar geometry. SRID 0 coordinates here are synthetic units, not metres.
DECLARE @shape geometry;
SET @shape = geometry::STGeomFromText(N'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 2 4, 4 4, 4 2, 2 2))', 0);
SELECT @shape.STExteriorRing().STAsText() AS outer_ring,
       @shape.STSrid AS source_srid,
       @shape.STIsValid() AS source_is_valid;

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