SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get record count for a specific database

By James Rea, 0001/01/01

Total article views: 17184 | Views in the last 30 days: 189

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.

By James Rea, 0001/01/01

Total article views: 17184 | Views in the last 30 days: 189
Your response
 
 
Related Articles
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 ...

FORUM

Flat file record count inside script task

how to get Flat file record count inside script task?

SCRIPT

Get Record count of all tables of current database

This script will return record count of all user tables from the current database

FORUM

When resultset of count is nothing

When resultset of count returns no records

Tags
 
Contribute

Free registration required...

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Login (existing users)

Login

Email:   Password:   Remember me: Forgotten your password?

Register (new users)

Register

Email:   Password:
Confirm:

Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

Steve Jones
Editor, SQLServerCentral.com