SQL Flow Field Guide

geography::EnvelopeAggregate

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

spatial aggregate EnvelopeAggregate

What changes

Input
spatial values of each group
Output or change
one geometry/geography per group
Return type
SQL Server return type: geography

Syntax at a glance

EnvelopeAggregate ( geography_operand )

Work example

Use geography.EnvelopeAggregate to compute one shared envelope around planar shapes.

Use it for bounds or candidate filtering rather than exact intersection. Keep the geography type and SRID in the review.

Check your work The aggregate encloses every input point and keeps the shared SRID 4326.

Practice SQL

Open in SQL Flow

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

SELECT geography::EnvelopeAggregate(v.shape).STGeometryType() AS envelope_type, geography::EnvelopeAggregate(v.shape).STSrid AS envelope_srid FROM (VALUES (geography::Point(47.653, -122.360, 4326)), (geography::Point(47.649, -122.348, 4326)), (geography::Point(47.658, -122.348, 4326))) AS v(shape);

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