SQL Flow Field Guide

geography.STNumGeometries

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

spatial method STNumGeometries (instance.STNumGeometries(...))

What changes

Input
spatial instance (and arguments)
Output or change
int
Return type
SQL Server return type: int CLR return type: SqlInt32

Syntax at a glance

.STNumGeometries ( )

Work example

Use geography.STNumGeometries to count members in a spatial collection.

Distinguish collection member count from point count. Keep the geography type and SRID in the review.

Check your work The MultiPoint contains two component geometries, so the count is 2.

Practice SQL

Open in SQL Flow

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

SELECT m.shape.STNumGeometries() AS component_count FROM (VALUES (geography::STGeomFromText('MULTIPOINT(-122.360 47.656, -122.343 47.656)', 4326))) AS m(shape);

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