Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

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
Source by www.mssqltips.com #
 
PREVIOUS NEXT
Tagged: #sQL #query #table #records #count #database
ADD COMMENT
Topic
Name
6+3 =