Get number of rows in each table of the database


/ Published in: SQL
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.