ptheriault
IS-IT--Management
I'm looking to create a list of all the tables and indexes in my database orderd by size desc. I have written the following but I'm not sure it's correct.
select a.object_id, a.name, a.type_desc, b.object_id, b.name, b.type_desc, c.rows
FROM sys.objects a join sys.indexes b on a.object_id = b.object_id
join sys.partitions c on c.object_id = a.object_id
WHERE a.name not like 'sys%'
order by c.rows desc
select a.object_id, a.name, a.type_desc, b.object_id, b.name, b.type_desc, c.rows
FROM sys.objects a join sys.indexes b on a.object_id = b.object_id
join sys.partitions c on c.object_id = a.object_id
WHERE a.name not like 'sys%'
order by c.rows desc