Solved

Get database name, table name and record count

Posted on 2014-11-24
4
93 Views
Last Modified: 2014-11-24
What query can I use to return the database name, table and record count for all the tables in a DB?

Would return  something like this

NORTHWIND       CATEGORIES             100
NORTHWIND      CUSTOMERS               500

etc.. etc..

thx
0
Comment
Question by:JElster
4 Comments
 
LVL 24

Assisted Solution

by:Phillip Burton
Phillip Burton earned 75 total points
Comment Utility
Right-hand click on your database, and go to Reports - Standard Reports - Disk Usage by Table.
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 350 total points
Comment Utility
EXEC sys.sp_MSforeachdb 'use ?;SELECT DISTINCT DB_NAME(), OBJECT_NAME(id), rowcnt FROM sys.sysindexes'
0
 
LVL 45

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 75 total points
Comment Utility
Try this one for each database:
SELECT OBJECT_NAME(id) TableName, rows
FROM sys.sysindexes s
WHERE id > 255 AND indid<=1
ORDER BY 1

Open in new window

0
 
LVL 65

Expert Comment

by:Jim Horn
Comment Utility
learn something new every day..
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SSRS Status field from text to number 2 26
Need help with a query. 10 42
Group by and order by clause 28 35
replication - alerts? 4 18
     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now