Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    31

    Unanswered: Finding some tables

    I have many tables in one database, and some of them are empty. How can I list / find (for eg. names) only non-empty tables?

  2. #2
    Join Date
    Aug 2006
    Location
    San Francisco, CA
    Posts
    136
    Code:
    SELECT 
        [TableName] = so.name, 
        [RowCount] = MAX(si.rows) 
    FROM 
        sysobjects so, 
        sysindexes si 
    WHERE 
        so.xtype = 'U' 
        AND 
        si.id = OBJECT_ID(so.name) 
    GROUP BY 
        so.name 
    ORDER BY 
        2 DESC

  3. #3
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    31
    Thanks! Works perfectly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •