SQL Flow Field Guide

geography::STGeomCollFromText

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

static constructor STGeomCollFromText (called as type::STGeomCollFromText(...))

What changes

Input
WKT, WKB, GML or coordinates and SRID
Output or change
spatial instance
Return type
SQL Server return type: geography CLR return type: SqlGeography

Syntax at a glance

STGeomCollFromText ( 'geometrycollection_tagged_text' , SRID )

Work example

Use geography.STGeomCollFromText to construct a collection from WKT.

Check member types and supply the coordinate SRID. Keep the geography type and SRID in the review.

Check your work The WKT builds a GeometryCollection with two components and assigns SRID 4326.

Practice SQL

Open in SQL Flow

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

SELECT geography::STGeomCollFromText('GEOMETRYCOLLECTION(POINT(-122.349 47.651), LINESTRING(-122.360 47.656, -122.343 47.656))', 4326).STGeometryType() AS collection_type, geography::STGeomCollFromText('GEOMETRYCOLLECTION(POINT(-122.349 47.651), LINESTRING(-122.360 47.656, -122.343 47.656))', 4326).STNumGeometries() AS component_count;

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