In SQL Server, the COUNT_BIG()
function and the COUNT()
do essentially the same thing: return the number of items found in a group. Basically, you can use these functions to find out how many rows are in a table or result set.
In many cases, you’ll be able to choose whichever one you prefer. However, there’s a difference between these two functions that might dictate that you to use one over the other.
The difference is that COUNT()
returns its result as an int, whereas COUNT_BIG()
returns its result as a bigint.
In other words, you’ll need to use COUNT_BIG()
if you expect its results to be larger than 2,147,483,647 (i.e. if the query returns more than 2,147,483,647 rows).