SQL Flow Field Guide

geography.AsBinaryZM

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

spatial method AsBinaryZM (instance.AsBinaryZM(...))

What changes

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

Syntax at a glance

.AsBinaryZM()

Work example

Use geography.AsBinaryZM to export binary coordinates with Z and M ordinates.

Confirm the destination supports the same dimensions and SRID. Keep the geography type and SRID in the review.

Check your work The binary output preserves both Z 10.3 and M 12; ordinary OGC WKB omits them.

Practice SQL

Open in SQL Flow

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

SELECT p.shape.AsBinaryZM() AS point_wkb_zm FROM (VALUES (geography::STGeomFromText('POINT(-122.34900 47.65100 10.3 12)', 4326))) AS p(shape);

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