Return a table list with row count


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

This will return a list of all the tables in a certain database along with their row count.


Copy this code and paste it in your HTML
  1. SELECT DISTINCT CONVERT(VARCHAR(30),object_name(a.id)) [TABLE Name], a.rows
  2. FROM sysindexes a INNER JOIN sysobjects b ON a.id = b.id
  3. INNER JOIN INFORMATION_SCHEMA.TABLES c ON c.[TABLE_NAME]=CONVERT(VARCHAR(30),object_name(a.id))
  4. WHERE c.Table_catalog='DATABASE NAME'

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.