Home Forums Programming General How to get the row count of a table? RE: How to get the row count of a table?

  • quote:


    You can use sp_spaceused @table_name which gives various bits of information about a table including the number of rows and is probably quicker than select count(*) from ....

    However, it is not always accururate but you can correct the information with sp_spaceused <table_name>, 'TRUE'. I forget when it gets out of sync with the actual table but I'm sure someone can remind me.


    sp_spaceused gets its data from (among other places) sysindexes. This data may be out of date if, for example, you've just deleted an index.

    Thomas Rushton
    blog: https://thelonedba.wordpress.com