Search This Blog

Finding the No.Of Rows of each table

CREATE Table #t (Name varchar(100), Row int, Reserved Varchar(32), data varchar(32), IndexSize varchar(32), Unused varchar(32))
INSERT INTO #tExec sp_MSforeachtable @command1="Exec sp_SpaceUsed '?' "
SELECT Name, RowFROM #t
DROP TABLE #t

1 comment:

Aneesh said...

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