Tables Without Clustered Indexes
--Doesn't work on 2000 databases or databases in 2000 compatability mode. Need to change the db_id() syntax if so.
select
[Database Name] = db_name()
, [Table Name] = s.name + '.' + o.name
, p.row_count
, SizeMb= (p.reserved_page_count*8.)/1024.
from
sys.objects o
inner join sys.schemas s on o.schema_id = s.schema_id
inner join sys.dm_db_partition_stats p on p.object_id = o.object_id
inner join sys.indexes si on si.object_id = o.object_ID
WHERE si.type_desc = 'Heap'
and is_ms_shipped = 0
order by SizeMb desc
No comments:
Post a Comment