Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mts
Starting Member
3 Posts |
Posted - 2010-06-03 : 18:44:24
|
| How do you get a list of tables and their row counts? I have tried this:SELECT [TableName] = so.name, [RowCount] = MAX(si.rows) FROM sysobjects so, sysindexes si WHERE so.xtype = 'U' AND si.id = OBJECT_ID(so.name) and so.name = 'TABLE_NAME'GROUP BY so.name ORDER BY 2 DESC; -- 14864select count(*) from TABLE_NAME; -- 14865For some reason the first query is showing one row less.Thanks,-- mts |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
mts
Starting Member
3 Posts |
Posted - 2010-06-04 : 10:32:21
|
| I'm not sure what version of SQL Server this database came from. I'm running these queries in 2005.I ran this:DBCC UPDATEUSAGE (Database_Name);I'm getting the same results. |
 |
|
|
|
|
|