SQL Flow Field Guide

geography::STMPolyFromWKB

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

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

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 OGC type: MultiPolygon

Syntax at a glance

STMPolyFromWKB ( 'WKB_multipolygon' , SRID )

Work example

Use geography.STMPolyFromWKB to construct a multi-polygon value from WKB bytes.

Validate member type, rings, and SRID at import. Keep the geography type and SRID in the review.

Check your work The WKB round trip returns both polygon components and receives SRID 4326 explicitly.

Practice SQL

Open in SQL Flow

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

SELECT geography::STMPolyFromWKB(s.shape.STAsBinary(), 4326).STNumGeometries() AS region_count FROM (VALUES (geography::STGeomFromText('MULTIPOLYGON(((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653)), ((-122.308 47.653, -122.298 47.649, -122.298 47.658, -122.308 47.658, -122.308 47.653)))', 4326))) AS s(shape);

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