Difference between COUNT_BIG and COUNT functions in SQL Server
COUNT() aggregate function is used in SQL to calculate the total count of items in a group.
COUNT_BIG() does the same calculation as COUNT() but difference is what they return.
The difference between the two is COUNT_BIG() returns a BigInt data type value And COUNT() return an Int data type.
Count calculates all null values as well in the group count calculation. All the other aggregate functions may exclude the null values in the calculations.
Examples,
| Code: |
| select COUNT(Distinct city) from tablepeople |
If you have millions of rows in a table, COUNT() may throw an error message so you can use COUNT_BIG function instead to avoid this data type error.
| Code: |
| select COUNT_BIG(id) from tablepeople |
Hope this hint may help someone out there.
Commentaires
Enregistrer un commentaire