Thursday, January 07, 2010

List all Tables of Database with No of Rows - SQLSERVER

This will get all the Table Names with no of rows in it.
use YourDBName
Go
SELECT
[TableName] = so.name,
[RowCount] = MAX(si.rows)
FROM
sysobjects so,
sysindexes si
WHERE
so.xtype = 'U'
AND
si.id = OBJECT_ID(so.name)
GROUP BY
so.name
ORDER BY 2 DESC