Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

count number of rows in every table 1

Status
Not open for further replies.

collierd2

MIS
Feb 26, 2007
61
DE
Hello

Using SQL 2000

What's the easiest way to list each table along with the record count within a specific database

Thanks
 
SELECT o.name, i.rowcnt
FROM sysindexes i join sysobjects o on i.id = o.id
WHERE indid < 2 and (OBJECTPROPERTY(object_id(o.name), N'IsTable')) = 1
order by 2 desc
 
Just an addition to Jamfool, if you want to see only YOUR tables you could use IsMsShipped property:
SELECT o.name, i.rowcnt
FROM sysindexes i
join sysobjects o on i.id = o.id
HERE indid < 2 AND
(OBJECTPROPERTY(object_id(o.name), N'IsTable')) = 1 AND
(OBJECTPROPERTY(object_id(o.name), N'IsMsShipped')) = 0
order by 2 desc
[/code]


Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top