sql select all records from all tables where not empty

Solutions on MaxInterview for sql select all records from all tables where not empty by the best coders in the world

showing results for - "sql select all records from all tables where not empty"
Adriana
03 Nov 2020
1SELECT r.table_name, r.row_count, r.[object_id]
2FROM sys.tables t
3INNER JOIN (
4    SELECT OBJECT_NAME(s.[object_id]) table_name, SUM(s.row_count) row_count, s.[object_id]
5    FROM sys.dm_db_partition_stats s
6    WHERE s.index_id in (0,1)
7    GROUP BY s.[object_id]
8) r on t.[object_id] = r.[object_id]
9WHERE r.row_count > 0
10ORDER BY r.table_name;