How to fetch the row count for all tables in a SQL SERVER database

 


Hello,
For SQL Server, it will be enough to run the following script to get the record counts in all tables.



SELECT t.name       AS table_name
       ,s.row_count AS row_count
FROM   sys.tables t
JOIN   sys.dm_db_partition_stats s
  ON t.OBJECT_ID = s.OBJECT_ID
 AND t.type_desc = 'USER_TABLE'
 AND s.index_id IN (0, 1)
ORDER  BY table_name;

Yorum Gönder

0 Yorumlar