geography.STAsText
spatial method STAsText (instance.STAsText(...))
What changes
- Input
- spatial instance (and arguments)
- Output or change
- nvarchar(max)
- Return type
- SQL Server return type: nvarchar(max) CLR return type: SqlChars
Syntax at a glance
.STAsText ( )
Work example
Use geography.STAsText to export OGC Well-Known Text.
Check whether the consumer needs Z or M ordinates. Keep the geography type and SRID in the review.
Check your work The WKT lists longitude before latitude; the method's text does not include the SRID.
Practice SQL
Open in SQL FlowOpen the SQL for a walkthrough. Run the example in SQL Server to check its result.
SELECT r.shape.STAsText() AS route_wkt FROM (VALUES (geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326))) AS r(shape);
Open Microsoft Learn for full syntax, permissions, and details for your version.