RSS Feed

SQL Count-Big

SQL COUNT_BIG

The COUNT_BIG function is similar to the COUNT function. The only difference between them is in relation to their return values: COUNT_BIG always returns a value of the BIGINT data type, while the COUNT function always returns a value of the INTEGER data type.

You can use this function when the count of a number of items in a resultset would exceed the range supported by the int datatype.

From MSDN: A view must meet these requirements before you can create a clustered index on it:

If GROUP BY is specified, the view select list must contain a COUNT_BIG(*) expression, and the view definition cannot specify HAVING, CUBE, or ROLLUP.

If a view already has a COUNT(*) in it, you cannot create a clustered index on it. For creating a clustered index change that count(*) to count_big(*).