SQL Flow Field Guide

geography::STPolyFromWKB

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

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

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: Polygon

Syntax at a glance

STPolyFromWKB ( 'WKB_polygon' , SRID )

Work example

Use geography.STPolyFromWKB to construct a polygon from WKB bytes.

Validate ring structure and SRID before containment tests. Keep the geography type and SRID in the review.

Check your work The WKB round trip returns a valid Polygon; SRID 4326 is supplied separately.

Practice SQL

Open in SQL Flow

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

SELECT geography::STPolyFromWKB(s.shape.STAsBinary(), 4326).STIsValid() AS polygon_is_valid FROM (VALUES (geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326))) AS s(shape);

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