All tablename and Record Count in a Database

,

Hello,

Here is a way that help in getting all the table name and rowcount with in a database
The use can give the database name and it will show the output for that database.

Output can be ordered by name or by number of rows.


To use it :

Copy the script and run paste in QA and run.

[tested on SQL 7/2000]


Raj-(Md.Sufian)
Thailand

SELECT 
    [TableName] = so.name, 
    [Table id]=so.id,
    [RowCount] = MAX(si.rows) 
 FROM 
sysobjects so, sysindexes si 
WHERE 
    so.xtype = 'U' 
    AND   si.id = OBJECT_ID(so.name) 
GROUP BY 
    so.name,so.id 
ORDER BY 
    2 DESC

Rate

Share

Share

Rate