The following query looks for the biggest tables in size (MB) and number of rows:
SELECT * FROM (SELECTtbl.NAME AS TableName,ind.name as indexName,sum(p.rows) as RowCounts,(sum(a.total_pages) * 8) / 1024 as TotalSpaceMB,(sum(a.used_pages) * 8) / 1024 as UsedSpaceMB,(sum(a.data_pages) * 8) / 1024 as DataSpaceMBFROMsys.tables tbl INNER JOINsys.indexes ind ON tbl.OBJECT_ID = ind.object_id INNER JOINsys.partitions p ON ind.object_id = p.OBJECT_ID AND ind.index_id = p.index_id INNER JOINsys.allocation_units a ON p.partition_id = a.container_idWHEREtbl.NAME NOT LIKE 'dt%' ANDind.OBJECT_ID > 255 ANDind.index_id <= 1GROUP BY tbl.NAME, ind.object_id, ind.index_id, ind.name) as t1 ORDER BY TotalSpaceMB desc ,UsedSpaceMB desc
No comments:
Post a Comment