Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8672559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:14:09+00:00 2026-06-12T19:14:09+00:00

I am trying to compress the largest tables in my database. I will do

  • 0

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…

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

Which returns:

            TABLE NAME   ROW COUNT
           PlannedShift  38268660
        BudgetStaffStat  19353104
          BudgetKBIStat  14142631
EmployeeShiftAdjustment  13493745
            Requirement  11020921
     EmployeeShiftError  6857235
      JobclassLaborData  5638692

and so on for all my tables.

I am looking for the same thing but returning page Count instead.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:14:10+00:00Added an answer on June 12, 2026 at 7:14 pm
    SELECT  OBJECT_SCHEMA_NAME(s.object_id) schema_name,
            OBJECT_NAME(s.object_id) table_name,
            SUM(s.used_page_count) used_pages,
            SUM(s.reserved_page_count) reserved_pages
    FROM    sys.dm_db_partition_stats s
    JOIN    sys.tables t
            ON s.object_id = t.object_id
    GROUP BY s.object_id
    ORDER BY schema_name,
            table_name;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to figure out how I can do this properly. The print_r looks like
I'm trying to figure out the best way to compress a stream with Python's
I'm trying to shrink this down... but can't figure out a way to do
I'm trying to automatically compress both CSS and JS using maven and this plugin
I'm trying to compress all traffic on port 6999 and pipe it out onto
I am trying to figure out the file layout of tar.Z file. (so called
I'm trying to compress any given string to a shorter version, copy paste-able compressed
I've encounted an error trying to implement Apache commons-compress in my Java application: java.lang.ClassNotFoundException:
I am trying to encode a list as JSON, compress it using gzip in
Trying to build out an exception if move.UserId does not equal currentUserId then Redirect

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.