SQL Flow Field Guide

geometry.Z

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

spatial method Z (instance.Z(...))

What changes

Input
spatial instance (and arguments)
Output or change
SQL Server type: float
Return type
SQL Server type: float CLR type: SqlDouble

Syntax at a glance

.Z

Work example

Read the Z ordinate from a geometry point when the source uses a third coordinate.

Check HasZ and document the vertical reference before treating Z as elevation.

Check your work Z is 5. SRID 0 defines no vertical datum, so this is not automatically elevation in metres.

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.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.