Table rowcount

  • Does any one have a script handy that gives you the rowcount of all user tables on a database. I have one but it gets the result from sysindexes which sometimes is notuptodate. Also I wont prefer anything witha  cursor as that might slow down the server. any scripts other than these two.


  • As you pointed out the sysindexes script only works if the index statistics are kept up-to-date. I think your best bet would be to keep them up-to-date and use the script otherwise you would have to use a script to run SELECT COUNT(*) FROM etc which would definitely not be efficient.

  • Unles you preffer doing a count(*) for each table which can be slow, I would suggest you keep using the index technic.

    If you don't want have out of date info, you can run this command prior to running the query : sp_updatestats

    This is also a good idea to put this in a periodic maintenance plan of the server.

    This a the query I used to get that info :

    Select O.Name, MAX(I.rowcnt) as 'RowCount' from dbo.SysIndexes I inner join dbo.SysObjects O on = and O.XType = 'U' where I.indid < 2 group by

  • Too much distraction here... can't post fast enough now .

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

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