SQL Flow Field Guide

geometry.HasZ

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

spatial method HasZ (instance.HasZ(...))

What changes

Input
spatial instance (and arguments)
Output or change
bit
Return type
SQL Server return type: bit CLR return type: Boolean

Syntax at a glance

.HasZ

Work example

Use geometry.HasZ to check whether elevation coordinates are present.

Document the vertical reference before using Z in calculations. Keep the geometry type and SRID in the review.

Check your work The point has Z=5. Geometry SRID 0 does not define a vertical datum.

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'POINT(3 4 5 6)', 0);
SELECT @shape.HasZ AS has_z, @shape.Z AS z_value,
       @shape.STSrid AS source_srid,
       @shape.STIsValid() AS source_is_valid;

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