SQL Server 2008 - find table with most rows

sql, sql-server, sql-server-2008, t-sql

Solution

This will get you close:

SELECT 
    [TableName] = so.name, 
    [RowCount] = MAX(si.rows) 
FROM 
    sysobjects so, 
    sysindexes si 
WHERE 
    so.xtype = 'U' 
    AND 
    si.id = OBJECT_ID(so.name) 
GROUP BY 
    so.name 
ORDER BY 
    2 DESC

Problem

Is there a way in SQL Server 2008 to find the table with the most rows in the database?

Original source