• Use this to get more detail about the internal storage of your table (clustered index) and non-clustered indexes, which includes avgerage fragmentation percentage and average page density.

    select

    schema_name(o.schema_id)schema_name,

    o.name obj_name,

    i.name idx_name,

    i.type_desc idx_type,

    ps.alloc_unit_type_desc,

    ps.record_count,

    ps.ghost_record_count,

    ps.forwarded_record_count,

    ps.compressed_page_count,

    cast(ps.avg_record_size_in_bytes as smallint)avg_recordsize_bytes,

    cast(ps.avg_fragmentation_in_percent as tinyint)avg_frag_pct,

    cast(ps.avg_page_space_used_in_percent as tinyint)avg_pageused_pct

    from sys.dm_db_index_physical_stats

    (DB_ID(), object_id('Table1'), NULL, NULL , 'SAMPLED') as ps

    join sys.objects o on ps.object_id = o.object_id

    join sys.indexes i on i.object_id = ps.object_id and i.index_id = ps.index_id

    order by i.object_id, i.index_id;

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho