SMSS中是否可以检测表是否有任何记录?我需要获取具有记录的表的列表。也许有一个sql语句可以解决问题?
一个更简单的语法:
SELECT [Name] = o.name, [RowCount]= SUM(p.row_count) FROM SYS.DM_DB_PARTITION_STATS p INNER JOIN SYS.TABLES o ON p.[object_ID] = o.[object_id] WHERE index_id <= 1 -- Heap or clustered index only GROUP BY o.name ORDER BY 2 desc