sql query to get all table records count from a database

Solutions on MaxInterview for sql query to get all table records count from a database by the best coders in the world

showing results for - "sql query to get all table records count from a database"
Mehtab
19 Nov 2017
1DECLARE @TableRowCounts TABLE ([TableName] VARCHAR(128), [RowCount] INT) ;
2INSERT INTO @TableRowCounts ([TableName], [RowCount])
3EXEC sp_MSforeachtable 'SELECT ''?'' [TableName], COUNT(*) [RowCount] FROM ?' ;
4SELECT [TableName], [RowCount]
5FROM @TableRowCounts
6ORDER BY [TableName]
7GO
8