Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favourite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved in your SSC briefcase from the favorites tab.
Download now (direct download link)

Get record count for a specific database

By James Rea,

I found it interesting to sometimes know how many records there are in my databases. This coding will allow you to count all of the records contained within any single user database you have created. It is very simple to switch databases to count (1 line of coding need be modified). You can also sort the results by either the record count or the table name.

This coding is a modification of a post I had found that would display all of the tables and their record counts. I found the original posting to also include other tables that may not hold as much relevance such as system tables, etc. You can view the original posting at: http://www.sqlservercentral.com/scripts/Miscellaneous/30324/

I have attempted to make it clear as to what is the original coding and what I had added, and what additional options you could look to use with this coding.

Total article views: 19379 | Views in the last 30 days: 88
 
Related Articles
SCRIPT

Count all records the tables

Count all the records from the tables that exist in a database

FORUM

Need DateTime format and count of records

Need DateTime format and count of records

FORUM

How do I count Analysis Services Databases?

Counting Databases

FORUM

Counting records over several tables

Wanting to count the number of records in each table after a certain date

SCRIPT

Get record count for a all databases

This is an addition to Jim Rea's "Get record count for a specific database". I modified it to loop ...

Tags
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones