SQL Flow Field Guide

CREATE AGGREGATE

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

defines a CLR user-defined aggregate

What changes

Input
module body (its own statements and their sources)
Output or change
module definition

Syntax at a glance

CREATE AGGREGATE [ schema_name . ] aggregate_name (@param_name <input_sqltype> [ ,...n ] ) RETURNS <return_sqltype> EXTERNAL NAME assembly_name [ .class_name ]

Work example

A reporting workload needs a CLR aggregate that built-in aggregates cannot express.

In a lab, trace the aggregate name to its assembly and inspect the assembly permission set and deployment owner.

Check your work The return type and aggregate behavior match the calling query and approved assembly.

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