var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Table list and record count
My boss would like a list of all the tables in a specific database and their record counts. There are over 80 tables in this database, so doing one by one is not something I have time for.
Does anyone know of a system table that stores this information or an easy way of doing this?
Never mind. I found it.
If anyone is interested it's:
select o.name, max(i.rowcnt) rowcnt
from sysindexes i inner join sysobjects o
on i.id = o.id
group by i.id, o.name
order by o.name
I generally prefer:
Note that this is
SELECT i.rowcnt, o.name
FROM dbo.sysindexes AS i
JOIN dbo.sysobjects AS o
ON (o.id = i.id)
WHERE i.indid IN (0, 1)
only accurate if your table statistics are current. When in doubt, use:
EXECUTE sp_updatestats 'RESAMPLE'
I had originally had the indid in (0,1). I wasn't getting all the tables. Some were being dropped. I found that the query above gave me one of each table. None being dropped.