geometry::STGeomCollFromText
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: geometry CLR return type: SqlGeometry
Syntax at a glance
STGeomCollFromText ( 'geometrycollection_tagged_text' , SRID )
Work example
Use geometry.STGeomCollFromText to construct a collection from WKT.
Check member types and supply the coordinate SRID. Keep the geometry type and SRID in the review.
Check your work The collection contains a point and line in the same SRID 0 planar frame.
Practice SQL
Open in SQL FlowOpen the SQL for a walkthrough. Run the example in SQL Server to check its result.
-- Planar geometry. SRID 0 coordinates here are synthetic units, not metres.
DECLARE @result geometry;
SET @result = geometry::STGeomCollFromText(N'GEOMETRYCOLLECTION(POINT(1 1), LINESTRING(0 0, 3 4))', 0);
SELECT @result.STAsText() AS collection_wkt,
@result.STSrid AS result_srid,
@result.STIsValid() AS result_is_valid;
Open Microsoft Learn for full syntax, permissions, and details for your version.