Sql query to get all table records count from a database

This article is tagged with: Sql query to get all table records count from a database and mysql

sQL query to get all table records count from a database

DECLARE @TableRowCounts TABLE ([TableName] VARCHAR(128), [RowCount] INT) ;
INSERT INTO @TableRowCounts ([TableName], [RowCount])
EXEC sp_MSforeachtable 'SELECT ''?'' [TableName], COUNT(*) [RowCount] FROM ?' ;
SELECT [TableName], [RowCount]
FROM @TableRowCounts
ORDER BY [TableName]
GO

This article is tagged with: Sql query to get all table records count from a database and mysql