SQL Server Management Studio - Finding all non empty tables

后端 未结 6 2105
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 02:00

Is there a way for SQL Server Management Studio Express How to list all the non empty tables? I have over 100 tables to go through and check for data.

6条回答
  •  醉酒成梦
    2020-12-16 02:30

    You could try using sysindexes and INFORMATION_SCHEMA.TABLES:)

    SELECT 'Table Name'=convert(char(25),t.TABLE_NAME),
          'Total Record Count'=max(i.rows)
    FROM sysindexes i, INFORMATION_SCHEMA.TABLES t
    WHERE t.TABLE_NAME = object_name(i.id)
          and t.TABLE_TYPE = 'BASE TABLE'
    GROUP BY t.TABLE_SCHEMA, t.TABLE_NAME
    HAVING max(i.rows)<=0
    

提交回复
热议问题