Q&A about the site for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles
USE StackOverflow ; SELECT GETDATE() AS 'Current DateTime' SELECT SCHEMA_NAME(t.schema_id) AS 'SchemaName', t.name AS 'TableName', SUM(p.rows) AS 'RowCount' FROM sys.tables t INNER JOIN sys.partitions p ON t.object_id = p.object_id WHERE p.index_id IN (0,1) -- 0 = table heap, 1 = clustered index GROUP BY t.schema_id, t.name ORDER BY t.name;