IsValidDetailed (geometry DataType)


Returns a message that can help to identify problems with a spatial object that is not valid. When the object is not valid, only the first error is returned. When the object is valid, a value of 24400 is returned.

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

SQL Server return type: nvarchar(max)

CLR return type: string

The following table contains possible return values:

Return valueDescription
24401Not valid, reason unknown.
24402Not valid because point {0} is an isolated point, which is not valid in this type of object.
24403Not valid because some pair of polygon edges overlap.
24404Not valid because polygon ring {0} intersects itself or some other ring.
24405Not valid because some polygon ring intersects itself or some other ring.
24406Not valid because curve {0} degenerates to a point.
24407Not valid because polygon ring {0} collapses to a line at point {1}.
24408Not valid because polygon ring {0} is not closed.
24409Not valid because some portion of polygon ring {0} lies in the interior of a polygon.
24410Not valid because ring {0} is the first ring in a polygon of which it is not the exterior ring.
24411Not valid because ring {0} lies outside the exterior ring {1} of its polygon.
24412Not valid because the interior of a polygon with rings {0} and {1} is not connected.
24413Not valid because of two overlapping edges in curve {0}.
24414Not valid because an edge of curve {0} overlaps an edge of curve {1}.
24415Not valid some polygon has an invalid ring structure.
24416Not valid because in curve {0} the edge that starts at point {1} is either a line or a degenerate arc with antipodal endpoints.

The following example of an invalid spatial object illustrates how the IsValidDetailed() methods behaves.

DECLARE @p GEOMETRY = 'Polygon((2 2, 4 4, 4 2, 2 4, 2 2))'  
SELECT @p.IsValidDetailed()  
--Returns: 24404: Not valid because polygon ring (1) intersects itself or some other ring.  

Extended Methods on Geometry Instances

Community Additions