Share via


STLength (geometry Data Type)

Returns the total length of the elements in a geometry instance.

Syntax

.STLength ( )

Return Types

SQL Server return type: float

CLR return type: SqlDouble

Remarks

If a geometry instance is closed, its length is calculated as the total length around the instance; the length of any polygon is its perimeter and the length of a point is 0. The length of any geometrycollection type is the sum of the lengths of its contained geometry instances.

Examples

The following example creates a LineString instance and uses STLength() to find the length of the instance.

DECLARE @g geometry;
SET @g = geometry::STGeomFromText('LINESTRING(0 0, 2 2, 1 0)', 0);
SELECT @g.STLength();

See Also

Other Resources