revvinghigh
Programmer
Need help on how to return all USER TABLES with its records count in 1 script?
thanks in advance!
thanks in advance!
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
CREATE TABLE #tmp (
table_name sysname,
record_count int
)
INSERT #tmp
EXEC sp_msforeachtable 'SELECT ''?'', COUNT(*) FROM ?'
SELECT * FROM #tmp
ORDER BY table_name
Table sysindexes, I think:ESquared said:If you have your statistics updated regulary you can also use the system count for each table if you don't need them to be 100% exact. I can't remember where this is off the top of my head. Anyone?
select A.name, B.rowcnt
from sysobjects A
inner join sysindexes B on A.id=B.id and B.indid in (0, 1)
where A.xtype = 'U'