Skip to main content

Show SQL Server database table details. Including row counts, object ID's and last modified time stamps.

select o.object_id,
    o.name,
    o.type,
    o.create_date,
    o.modify_date,
    t.lock_escalation,
    --CAST(ep.value as nvarchar(max)) as comment,
    --ct.is_track_columns_updated_on,
    st.row_count
from sys.all_objects as o
left join sys.schemas as s
    on o.schema_id = s.schema_id
left join sys.tables as t
    on o.object_id = t.object_id
left join sys.extended_properties as ep
    on o.object_id = ep.major_id
        and ep.class = 1
        and ep.minor_id = 0
        and ep.name = 'MS_Description'
left join (select object_id, sum(rows) as row_count from sys.partitions where index_id < 2 group by object_id) as st
    on o.object_id = st.object_id
left join sys.change_tracking_tables as ct
    on o.object_id = ct.object_id
where o.type = 'U'
order by st.row_count desc;