Monday, November 06, 2006

T-SQL to list all the user tables and row counts in a DB

SELECT distinct B.[name] as [Table Name], max(A.rowcnt) as [Row Count]FROM sysindexes AINNER JOIN sysobjects BON = B.idWHERE B.type = 'U'GROUP BY B.[name]ORDER BY B.[name]

The above query returns all the user tables and the count of all rows in the current DB.


Post a Comment

<< Home