Customer Support Portal
Language
 
Home>Knowledge Base>Root>DNN Development>How can I quickly get a row count for the tables in my database?
User Login
Username
Password
 
 Login
Information
Article ID35
Created On1/28/2011
Modified1/28/2011
Share With Others

How can I quickly get a row count for the tables in my database?

In order to get a good overview of the state of your database sometimes it is convenient to know which tables contain the most data rows. The following query shows you the row count for all your database tables. You can run it in MSSQL Management Studio or directly from your DNN site from Host > SQL.

SELECT        o.name, ddps.row_count
FROM            sys.indexes AS i INNER JOIN
                         sys.objects AS o ON i.object_id = o.object_id INNER JOIN
                         sys.dm_db_partition_stats AS ddps ON i.object_id = ddps.object_id AND i.index_id = ddps.index_id
WHERE        (i.index_id < 2) AND (o.is_ms_shipped = 0)
ORDER BY ddps.row_count DESC