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 A.id = 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.

0 Comments:

Post a Comment

<< Home