• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 114
  • Last Modified:

Get database name, table name and record count

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
JElster
Asked:
JElster
3 Solutions
 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
Right-hand click on your database, and go to Reports - Standard Reports - Disk Usage by Table.
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
EXEC sys.sp_MSforeachdb 'use ?;SELECT DISTINCT DB_NAME(), OBJECT_NAME(id), rowcnt FROM sys.sysindexes'
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
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
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
learn something new every day..
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now