title: Determining page count on each SQL table without using DBCC
body: <p>I am trying to compress the largest tables in my database. I will do this by running the SP_ForEachDB stored procedure. However I cannot figure out how to view the total page count. I can get the row count with this query...</p>
  
  <pre><code>USE DEVELOP04_HiltonUS
  
  GO
  
  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
  </code></pre>
  
  <p>Which returns:  </p>
  
  <pre><code>            TABLE NAME   ROW COUNT
             PlannedShift  38268660
          BudgetStaffStat  19353104
            BudgetKBIStat  14142631
  EmployeeShiftAdjustment  13493745
              Requirement  11020921
       EmployeeShiftError  6857235
        JobclassLaborData  5638692
  </code></pre>
  
  <p>and so on for all my tables.</p>
  
  <p>I am looking for the same thing but returning page Count instead.</p>