HOWTO: Find out the Sizes and Rowcounts of All the User Tables in a Database in SQL (UPDATED! - Now includes the RedGate SQLPrompt Snippet Text)
Here is an update on a blog post that I wrote a decade ago for finding the size and rowcounts for all user tables in a database: --For storing values in the cursor DECLARE @TableName VARCHAR(100) DECLARE @SchemaNameAndTableName VARCHAR(100) --Cursor to get the name of all user tables from the sysobjects listing DECLARE tableCursor CURSOR FAST_FORWARD READ_ONLY FOR SELECT so.name AS TableName, s.name + '.' + so.name AS FullTableName FROM sys.objects so INNER JOIN sys.schemas AS s ON so.schema_id = s.schema_id WHERE so.type = 'U' AND s.name + '.' + so.name LIKE '%%' ORDER BY FullTableName --A procedure level temp table to store the results DECLARE @TempTable AS Table ( ...