SQL Server 2008: I have 1000 tables, I need to know which tables have data

Viewed 28562

Is there a way in SMSS to detect whether a table has any records? I need to get a list of tables that have records. perhaps there is a sql statement that will do the trick?

5 Answers

Hope, It helps you-

SELECT name AS [TableList] FROM SYS.DM_DB_PARTITION_STATS s 
INNER JOIN sys.tables t ON t.[object_id] = s.[object_id]
WHERE row_count = 0

This code shows that list of tables, which does not contain any data or row.

Thanks!!!

Related