I'm doing a query in SQL SERVER. I need to know the object, type object, size of the object, indexes that have that object and the percentage of fragmentation of each index.
My doubt lies in the tables to be able to bring the fragmentation of each index and the size of the object.
This is what I have:
select distinct so.name,so.type,(so.type_desc),ps.row_count as
IdnIsThisIsSize,idx.index_id from sys.objects so
inner join sys.dm_db_partition_stats ps
on so.object_id = ps.object_id inner join sys.indexes idx on
idx.index_id = ps.index_id;