Posted By

blackf0rk on 04/28/09


Tagged

table list count return row


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

flurk118


Return a table list with row count


 / Published in: SQL
 

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

  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  

You need to login to post a comment.