Posted By

plugables on 09/11/11


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

johnw


Get number of rows in each table of the database


 / Published in: SQL
 

Get number of rows in each table of the database (MSSQL)

  1. CREATE TABLE #tmpOutput (TableName VARCHAR(300), TableRowCount INT)
  2. EXEC dbo.sp_MSForEachTable 'INSERT INTO #tmpOutput(TableName, TableRowCount) SELECT ''?'', COUNT(*) FROM ?'
  3. SELECT TableName, TableRowCount
  4. FROM #tmpOutput
  5. ORDER BY TableRowCount DESC
  6. DROP TABLE #tmpOutput

Report this snippet  

You need to login to post a comment.