SQL Flow Field Guide

COUNT_BIG

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

aggregation

What changes

Input
the argument expression over each group's rows (COUNT(*) reads no column)
Output or change
one value per group (or one for the whole input when there is no GROUP BY)
Return type
bigint

Syntax at a glance

COUNT_BIG ( { [ [ ALL | DISTINCT ] expression ] | * } )

Work example

Count a result whose row total could exceed the int range.

Use COUNT_BIG in warehouse totals and keep the receiving expression as bigint.

Check your work The result is bigint, so downstream casts can still narrow it by mistake.

Practice SQL

Open in SQL Flow
SELECT COUNT_BIG(*) AS row_count FROM (VALUES (1), (2), (3)) AS v(n);

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