Skip to main content
Skip table of contents

MS SQL Tables and Row Counts

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

CODE
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

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.