geometry.STIsValid
spatial predicate STIsValid
What changes
- Input
- one or two spatial instances
- Output or change
- bit
- Return type
- SQL Server return type: bit CLR return type: SqlBoolean
Syntax at a glance
.STIsValid ( )
Work example
Use geometry.STIsValid to check whether a shape meets spatial validity rules.
Validate imported polygons before area and overlay calculations. Keep the geometry type and SRID in the review.
Check your work The bow-tie polygon returns STIsValid=0. Validity checks OGC shape rules, not coordinate reference.
Practice SQL
Open in SQL FlowOpen 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 validity_detail,
@shape.STSrid AS source_srid,
@shape.STIsValid() AS source_is_valid;
Open Microsoft Learn for full syntax, permissions, and details for your version.