Tables with max size

  • Hi all,

    I would like to clean some our tables (delete old records we don’t use for a while). So I am wondering is there a way to find somehow tables size (number of records) not checking “Property”- Rows for every table?

    Thanks

  • If they all have indexes, you can query sysobjects for types of "U" and join that with the sysindexes to get the row counts.

  • This is what he means :

    Select O.Name as TableName, max(I.rowcnt) as Total from dbo.sysindexes I inner join dbo.SysObjects O on i.id = O.id and O.Status >=0 and O.XType = 'U' and I.indid < 2 Group by I.id, O.Name order by Total Desc

  • Thanks a lot!

    And there is no direct way to find table size (Mb) besides manual calculation using rows number I've got?

  • Search the script section on this site for table size and you'll get a few exemples.

  • Thanks again.

  • Run this query in the desired database will give you your required information"

    sp_msforeachtable 'sp_spaceused ''?'''

     

    hope this will help.

    Thanks.

  • Also, in Enterprise Manager, Task Pad view, Table Info, you can see the estimated (from sysindexes) size in KB.

    Steve

  • Cool! Thanks a lot for both tips!.

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply