What is the functional difference between @@ROWCOUNT and ROWCOUNT_BIG function?

@@RowCount vs RowCount_Big():

Functionally there is no difference between these two. Both returns the number of records returned by the last executed SQL statement. But the return value of @@ROWCOUNT is INT whereas the return type of ROWCOUNT_BIG () is BigInt.

                If the table records exceed 2 Billion records, use ROWCOUNT_BIG() instead of @@ROWCOUNT. @@ROWCOUNT can count till 2,147,483,647 rows. If the table records exceed this number, we should use ROWCOUNT_BIG().

Ex:

———————————————————
USE AdventureWorks2008R2
GO
———————————————————

— ROWCOUNT Ex
———————————————————
SELECT TOP 2 * FROM [Person].[Person]
SELECT @@ROWCOUNT RC
———————————————————
— ROWCOUNT_BIG() Ex
———————————————————
SELECT TOP 2 * FROM [Person].[Person]
SELECT ROWCOUNT_BIG() RC_BIG
———————————————————

Result:

RowCount_Big

Happy Reading :)

Leave a Reply

Your email address will not be published. Required fields are marked *