Answers for "get row counts for all tables in a database"

SQL
1

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
Posted by: Guest on April-25-2020

Code answers related to "get row counts for all tables in a database"

Code answers related to "SQL"

Browse Popular Code Answers by Language