Solved

Get database name, table name and record count

Posted on 2014-11-24
4
107 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 50

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Negative isnull? 3 32
Reformat SQL - so SSRS can read the columns 25 47
query output (script) from a stored procedure 4 54
Need to replicate a Log table 4 41
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 …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

752 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