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

  By Junaid A   Posted on July-29-2022   166

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

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 Views  166



You may also read following recent Post