How to list all empty tables in your database in SQL Server

   Use AdventureWorks2012

go

;WITH Empty AS
(
SELECT
OBJECT_NAME(OBJECT_ID) [Table],
SUM(row_count) [Records]
FROM
sys.dm_db_partition_stats
WHERE
index_id = 0 OR index_id = 1
GROUP BY
OBJECT_ID
)

SELECT [Table],Records
FROM [Empty]
WHERE [Records] = 0

Leave a Reply

Your email address will not be published. Required fields are marked *