Tuesday, 25 April 2017

How Use sp_MSForEachTable SP for Tables Row Count

Easiest way to get row count of every table in a database. You can use sp_MSForEachTable
SP

CREATE TABLE #Tablescounts

(table_name varchar(255),row_count int)

 

EXEC sp_MSForEachTable @command1 = 'INSERT #Tablescounts (table_name, row_count) SELECT ''?'', COUNT(*) FROM ?'

 

SELECT * FROM #Tablescounts



WHAT OTHERS ARE READING/RELATED TO THIS:

0 comments:

Post a Comment