SQL Flow Field Guide

geometry.IsValidDetailed

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

spatial method IsValidDetailed (instance.IsValidDetailed(...))

What changes

Input
spatial instance (and arguments)
Output or change
nvarchar(max)
Return type
SQL Server return type: nvarchar(max) CLR return type: string

Syntax at a glance

.IsValidDetailed()

Work example

Use geometry.IsValidDetailed to read a diagnostic for an invalid spatial value.

Review the reason before deciding whether MakeValid is acceptable. Keep the geometry type and SRID in the review.

Check your work The self-crossing bow-tie returns STIsValid=0 and IsValidDetailed explains its first OGC validity issue.

Practice SQL

Open in SQL Flow

Open the SQL for a walkthrough. Run the example in SQL Server to check its result.

-- Planar geometry. SRID 0 coordinates here are synthetic units, not metres.
DECLARE @shape geometry;
SET @shape = geometry::STGeomFromText(N'POLYGON((0 0, 4 4, 0 4, 4 0, 0 0))', 0);
SELECT @shape.STIsValid() AS is_valid, @shape.IsValidDetailed() AS first_validity_diagnostic,
       @shape.STSrid AS source_srid,
       @shape.STIsValid() AS source_is_valid;

Open Microsoft Learn for full syntax, permissions, and details for your version.