SQL Flow Field Guide

geography.STLength

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

spatial method STLength (instance.STLength(...))

What changes

Input
spatial instance (and arguments)
Output or change
float
Return type
SQL Server return type: float CLR return type: SqlDouble

Syntax at a glance

.STLength ( )

Work example

Use geography.STLength to measure the length of curve elements.

For geometry record coordinate units. For geography check SRID units. Keep the geography type and SRID in the review.

Check your work The route length is measured in metres for this geography instance.

Practice SQL

Open in SQL Flow

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

SELECT r.shape.STLength() AS route_length_metres 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.