Script to enumertae size, #rows in DB tables

  • Other than by using sp_spaceused in a cursor how can I determine the size and rowcount of each table in a given database?

    Bill

  • EXEC sp_MSforeachtable "print '?' dbcc checktable ('?')"

  • select object_name(ind.id) as TableName, ind.rows as RowCount

    from sysindexes ind, sysobjects obj

    where (ind.indid = 1 or ind.indid = 0)

    and obj.id = ind.id

    and obj.xtype = 'U'

    order by object_name(ind.id)

    You have to run DBCC UPDATEUSAGE corrects the rows, used, reserved, and dpages columns of the sysindexes table for tables and clustered indexes, otherwise, you may see inaccuracies.

Viewing 3 posts - 1 through 2 (of 2 total)

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