Home >

SQL Server: Get Accurate Count of Rows for Large Tables

3. March 2011

Here is the query which is not only quick but reliable enough to retrieve accurate number of rows in a very large table like a table with 2,000,000,000,000+ rows table :)

 

 

SELECT SUM (row_count)

FROM sys.dm_db_partition_stats

WHERE object_id=OBJECT_ID('<table name>')

AND (index_id=0 or index_id=1);

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading