To get the record count of each table in the database at once.
CREATE TABLE #RecordCount
(
TableName varchar(500),
NoOfRows int
)
EXEC sp_MSForEachTable @command1='INSERT #RecordCount(TableName , NoOfRows) SELECT ''?'', COUNT(*) FROM ?'
SELECT TableName , NoOfRows FROM #RecordCount ORDER BY TableName , NoOfRows DESC
CREATE TABLE #RecordCount
(
TableName varchar(500),
NoOfRows int
)
EXEC sp_MSForEachTable @command1='INSERT #RecordCount(TableName , NoOfRows) SELECT ''?'', COUNT(*) FROM ?'
SELECT TableName , NoOfRows FROM #RecordCount ORDER BY TableName , NoOfRows DESC