I know that I can get a list of tables with
SELECT TABLE_NAME FROM information_schema.tables
WHERE NOT TABLE_NAME='sysdiagrams'
AND TABLE_SCHEMA = 'dbo'
AND TABLE_TYPE= 'BASE TABLE'
But I'm not sure how to modify that to get a 2nd column with the current count of rows for the tables. I though of something like this:
DECLARE @tbl VARCHAR(200)
(SELECT @tbl = TABLE_NAME, TABLE_NAME,
(SELECT COUNT(ID) AS Cnt FROM @tbl)
FROM information_schema.tables
WHERE NOT TABLE_NAME='sysdiagrams'
AND TABLE_SCHEMA = 'dbo'
AND TABLE_TYPE= 'BASE TABLE')
I know the above is not valid T-SQL but I think it gets the point of what I would like the have done. This is for SQL Server 2000. I would prefer not to use store procedures if at all possible.
You can go whole hog on this one. The problem with using sysIndexes to get rowcounts is that they're not always up to date. There is a way to make them all up to date, though. The following code will give you row counts for each table and a whole bunch more.
how about "dtproperties" and "sysdiagrams" ? these tables will show up as user table incorrectly
A quick and dirty way (includes uncommitted changes and possibly forwarding pointers on heaps)