|
|
Cry How to...Count the total number of records in all user tablesI once had a management request for the total number of records in a database. This may not be a particularly useful statistic, but ... To count the number of records in a table: select count(*) from <table-name> To count the number of user-tables: select count(*) from sysobjects where type='U' To count the total number of records in all the user tables (this uses cursors to loop through considering each table at a time):
These notes have been tested against SQL Server 2000. About the author: Brian Cryer is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant. |