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
No comments:
Post a Comment
Please include your thoughts/suggestion to make it as a better blog. If you find it useful, Please update with your valuable comments, so that others can use it.