SQL Server Performance

Top Tables

Discussion in 'Contribute Your SQL Server Scripts' started by trabant, Jan 10, 2005.

  1. trabant New Member

    This code pulls out the biggest tables in your system and returns a result set. Copy and paste the result set into query analyser and execute - This returns Showcontig information about your top tables, biggest first.

    Change the top 5 for whatever number you want. Also handy for DBCC dbreindex.

    Simple but pretty useful.......

    select top 5
    'dbcc showcontig(' + cast(id as nvarchar(20)) + ')'
    + char(10) +
    'print '' '''+ char(10)
    from sysindexes
    where indid = 1 or
    indid = 0
    order by rows desc

    Petew

Share This Page