geometry::STMPolyFromText
static constructor STMPolyFromText (called as type::STMPolyFromText(...))
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: Sql Geometry OGC type: MultiPolygon
Syntax at a glance
STMPolyFromText ( 'multipolygon_tagged_text' , SRID )
Work example
Use geometry.STMPolyFromText to construct a multi-polygon value from WKT.
Check ring closure, geography orientation, and SRID. Keep the geometry type and SRID in the review.
Check your work The MultiPolygon contains two valid, separated polygon members.
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::STMPolyFromText(N'MULTIPOLYGON(((0 0, 2 0, 2 2, 0 2, 0 0)),((4 0, 6 0, 6 2, 4 2, 4 0)))', 0);
SELECT @result.STAsText() AS multipolygon_wkt,
@result.STSrid AS result_srid,
@result.STIsValid() AS result_is_valid;
Open Microsoft Learn for full syntax, permissions, and details for your version.