Skip to content

Latest commit

 

History

History
64 lines (46 loc) · 2.23 KB

stpointn-geography-data-type.md

File metadata and controls

64 lines (46 loc) · 2.23 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
STPointN (geography Data Type)
STPointN (geography Data Type)
MladjoA
mlandzic
03/14/2017
sql
t-sql
reference
STPointN_TSQL
STPointN (geography Data Type)
STPointN method
TSQL

STPointN (geography Data Type)

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

Returns the specified point in a geography instance.

Syntax

  
.STPointN ( expression )  

[!INCLUDEsql-server-tsql-previous-offline-documentation]

Arguments

expression
Is an int expression between 1 and the number of points in the geography instance.

Return Types

[!INCLUDEssNoVersion] return type: geography

CLR return type: SqlGeography

Open Geospatial Consortium (OGC) type: Point

Remarks

If a geography instance is user-created, STPointN() returns the point specified by expression by ordering the points in the order in which they were originally input.

If a geography instance is constructed by the system, STPointN() returns the point specified by expression by ordering all the points in the same order they would be output: first by geography instance, then by ring within the instance (if appropriate), and then by point within the ring. This order is deterministic.

If this method is called with a value less than 1, it throws an ArgumentOutOfRangeException.

If this method is called with a value greater than the number of points in the instance, it returns null.

Examples

The following example creates a LineString instance and uses STPointN() to retrieve the second point in the description of the instance.

DECLARE @g geography;  
SET @g = geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326);  
SELECT @g.STPointN(2).ToString();  

See Also

OGC Methods on Geography Instances