STGeometryN (geometry Data Type)

Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance SQL analytics endpoint in Microsoft Fabric Warehouse in Microsoft Fabric

Returns a specified geometry in a geometry collection.

Syntax

  
.STGeometryN ( expression )  

Note

To view Transact-SQL syntax for SQL Server 2014 (12.x) and earlier versions, see Previous versions documentation.

Arguments

expression
Is an int expression between 1 and the number of geometry instances in the geometrycollection.

Return Types

SQL Server return type: geometry

CLR return type: SqlGeometry

Remarks

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.

Examples

The following example creates a MultiPoint``geometry collection and uses STGeometryN() to find the second geometry instance of the collection.

DECLARE @g geometry;  
SET @g = geometry::STGeomFromText('MULTIPOINT(0 0, 13.5 2, 7 19)', 0);  
SELECT @g.STGeometryN(2).ToString();  

See Also

OGC Methods on Geometry Instances