NumRings (geography Data Type)
Applies To: SQL Server 2014, SQL Server 2016 Preview
Returns the total number of rings in a Polygon instance. In the SQL Server geography type, external and internal rings are not distinguished, as any ring can be taken to be the external ring.
Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database.
SQL Server return type: int
CLR return type: SqlInt32
This method will return NULL if this is not a Polygon instance and will return 0 if the instance is empty. This method is precise.
This example creates a Polygon instance with two rings and confirms that it has two rings.
DECLARE @g geography; SET @g = geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653), (-122.357 47.654, -122.357 47.657, -122.349 47.657, -122.349 47.650, -122.357 47.654))', 4326); SELECT @g.NumRings();