geometry.STInteriorRingN
spatial method STInteriorRingN (instance.STInteriorRingN(...))
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
.STInteriorRingN ( expression )
Work example
Use geometry.STInteriorRingN to read one interior ring from a polygon.
Check the polygon and one-based ring index before treating it as a hole. Keep the geometry type and SRID in the review.
Check your work The polygon has one interior ring. The first ring index is 1.
Practice SQL
Open in SQL FlowOpen 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.STInteriorRingN(1).STAsText() AS first_hole_ring, @shape.STNumInteriorRing() AS hole_count,
@shape.STSrid AS source_srid,
@shape.STIsValid() AS source_is_valid;
Open Microsoft Learn for full syntax, permissions, and details for your version.