SQL Flow Field Guide

geography::STLineFromText

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

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

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

Syntax at a glance

STLineFromText ( 'linestring_tagged_text' , SRID )

Work example

Use geography.STLineFromText to construct a line from WKT coordinates.

Check point count and source SRID. Keep the geography type and SRID in the review.

Check your work The LineString WKT creates a geography route and its length is returned in metres.

Practice SQL

Open in SQL Flow

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

SELECT geography::STLineFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326).STLength() AS route_length_metres;

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