MS SQL Tables and Row Counts

Run the query below in SSMS to view the tables and their row counts:

USE DB_name GO SELECT (t.name) as tablen, (s.name) as scheman, max(p.rows) as rows FROM sys.partitions AS p WITH (NOLOCK) INNER JOIN sys.tables AS t WITH (NOLOCK) ON p.[object_id] = t.[object_id] INNER JOIN sys.schemas AS s WITH (NOLOCK) ON s.[schema_id] = t.[schema_id] GROUP BY t.name, s.name ORDER BY s.name, t.name