SQL Flow Field Guide

geography::STMLineFromWKB

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

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

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

Syntax at a glance

STMLineFromWKB ( 'WKB_multilinestring' , SRID )

Work example

Use geography.STMLineFromWKB to construct a multi-line value from WKB bytes.

Check expected line members and SRID. Keep the geography type and SRID in the review.

Check your work The WKB round trip returns the two route components; 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::STMLineFromWKB(s.shape.STAsBinary(), 4326).STNumGeometries() AS route_count FROM (VALUES (geography::STMLineFromText('MULTILINESTRING ((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653), (-122.357 47.654, -122.357 47.657, -122.349 47.657, -122.349 47.650, -122.357 47.654))', 4326))) AS s(shape);

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