Solved

Get database name, table name and record count

Posted on 2014-11-24
4
99 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
ID: 40462447
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
ID: 40462453
EXEC sys.sp_MSforeachdb 'use ?;SELECT DISTINCT DB_NAME(), OBJECT_NAME(id), rowcnt FROM sys.sysindexes'
0
 
LVL 47

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 75 total points
ID: 40462465
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
ID: 40462508
learn something new every day..
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

813 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

18 Experts available now in Live!

Get 1:1 Help Now