Select all empty tables in SQL Server -
is possible list sql server of tables in data base not have records in them?
on sql server 2005 , up, can use this:
;with tablerows ( select sum(row_count) [rowcount], object_name(object_id) tablename sys.dm_db_partition_stats index_id = 0 or index_id = 1 group object_id ) select * tablerows [rowcount] = 0 the inner select in cte (common table expression) calculates number of rows each table , groups them table (object_id), , outer select cte grabs rows (tables) have total number of rows equal zero.
Comments
Post a Comment