geography::STGeomCollFromWKB
static constructor STGeomCollFromWKB (called as type::STGeomCollFromWKB(...))
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
STGeomCollFromWKB ( 'WKB_geometrycollection' , SRID )
Work example
Use geography.STGeomCollFromWKB to construct a collection from WKB bytes.
Keep binary format and SRID together in the import contract. Keep the geography type and SRID in the review.
Check your work The WKB round trip returns the collection's two components; SRID 4326 is supplied separately.
Practice SQL
Open in SQL FlowOpen the SQL for a walkthrough. Run the example in SQL Server to check its result.
SELECT geography::STGeomCollFromWKB(s.shape.STAsBinary(), 4326).STNumGeometries() AS component_count FROM (VALUES (geography::STGeomFromText('GEOMETRYCOLLECTION(POINT(-122.349 47.651), LINESTRING(-122.360 47.656, -122.343 47.656))', 4326))) AS s(shape);
Open Microsoft Learn for full syntax, permissions, and details for your version.