Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1.94 KB

stlength-geometry-data-type.md

File metadata and controls

54 lines (40 loc) · 1.94 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs monikerRange
STLength (geometry Data Type)
STLength (geometry Data Type)
MladjoA
mlandzic
08/03/2017
sql
t-sql
reference
STLength_TSQL
STLength (geometry Data Type)
STLength (geometry Data Type)
TSQL
=azuresqldb-current||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current

STLength (geometry Data Type)

[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance]

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

Syntax

  
.STLength ( )  

Return Types

[!INCLUDEssNoVersion] 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.

STLength() works on both valid and invalid LineStrings. Typically a LineString is invalid due to overlapping segments, which may be caused by anomalies such as inaccurate GPS traces. STLength() does not remove overlapping or invalid segments. It includes overlapping and invalid segments in the length value that it returns. The MakeValid() method can remove overlapping segments from a LineString.

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

OGC Methods on Geometry Instances