SQL Flow Field Guide

geography.STAsBinary

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

spatial method STAsBinary (instance.STAsBinary(...))

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

.STAsBinary ( )

Work example

Use geography.STAsBinary to export OGC Well-Known Binary.

Check whether the consumer needs Z or M ordinates. Keep the geography type and SRID in the review.

Check your work The binary is OGC WKB for the point; WKB does not carry the geography SRID.

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.STAsBinary() AS point_wkb FROM (VALUES (geography::Point(47.651, -122.349, 4326))) AS p(shape);

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