Export (0) Print
Expand All

STGeometryN (geography 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 geography element in a GeometryCollection or one of its subtypes. When STGeometryN() is used on a subtype of a GeometryCollection, such as MultiPoint or MultiLineString, this method returns the geography instance if called with N=1.

Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database.

.STGeometryN ( expression )

expression

Is an int expression between 1 and the number of geography instances in the GeometryCollection.

SQL Server return type: geography

CLR return type: SqlGeography

This method returns null if the parameter is larger than the result of STNumGeometries() and will throw an ArgumentOutOfRangeException if the expression parameter is less than 1.

The following example creates a MultiPoint geography instance and uses STGeometryN() to find the second geography instance of the GeometryCollection.

DECLARE @g geography;
SET @g = geography::STGeomFromText('MULTIPOINT(-122.360 47.656, -122.343 47.656)', 4326);
SELECT @g.STGeometryN(2).ToString();
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2015 Microsoft