STPointN (geometry Data Type)
Applies To: SQL Server 2014, SQL Server 2016 Preview
Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).
Returns a specified point in a geometry instance.
Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database.
If a geometry 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 geometry instance was 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 geometry, then by ring within the geometry (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.
The following example creates a LineString instance and uses STPointN() to retrieve the second point in the description of the instance.
DECLARE @g geometry; SET @g = geometry::STGeomFromText('LINESTRING(0 0, 2 2, 1 0)', 0); SELECT @g.STPointN(2).ToString();