Post

how to check tables and number of rows in each table in ms sql server?

how to check tables and number of rows in each table in ms sql server.

SELECT [Tables].name AS [TableName],
 SUM( [Partitions].[rows] ) AS [TotalRowCount]
FROM sys.tables AS [Tables]
JOIN sys.partitions AS [Partitions]
 ON [Tables].[object_id] = [Partitions].[object_id]
 AND [Partitions].index_id IN ( 0, 1 )
--WHERE [Tables].name = N'table name' /* uncomment to look for a specific table */
GROUP BY [Tables].name

By  asifjans    29-Jul-2022

Solutions and sugestions


Your Answer