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 213599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:17:38+00:00 2026-05-11T18:17:38+00:00

i’ve got around 10 tables in my sql 2008 server. Currently, my mdf is

  • 0

i’ve got around 10 tables in my sql 2008 server.

Currently, my mdf is around 3.5Gig. (I also have some binary data in some of the tables). So, I’m wondering if there’s a way i could see which tables are the biggest in size.

Is this possible?

Maybe it’s an index or FTS catalog 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-05-11T18:17:38+00:00Added an answer on May 11, 2026 at 6:17 pm

    run this:

    /******************************************************************************
    **    File: “GetTableSpaceUseage.sql”
    **    Name: Get Table Space Useage for a specific schema
    **    Auth: Robert C. Cain
    **    Date: 01/27/2008
    **
    **    Desc: Calls the sp_spaceused proc for each table in a schema and returns
    **        the Table Name, Number of Rows, and space used for each table.
    **
    **    Called by:
    **     n/a – As needed
    **
    **    Input Parameters:
    **     In the code check the value of @schemaname, if you need it for a
    **     schema other than dbo be sure to change it.
    **
    **    Output Parameters:
    **     NA
    *******************************************************************************/
    
    /*—————————————————————————*/
    /* Drop the temp table if it's there from a previous run                     */
    /*—————————————————————————*/
    if object_id(N'tempdb..[#TableSizes]') is not null
      drop table #TableSizes ;
    go
    
    /*—————————————————————————*/
    /* Create the temp table                                                     */
    /*—————————————————————————*/
    create table #TableSizes
      (
        [Table Name] nvarchar(128)   /* Name of the table */
      , [Number of Rows] char(11)    /* Number of rows existing in the table. */
      , [Reserved Space] varchar(18) /* Reserved space for table. */
      , [Data Space] varchar(18)    /* Amount of space used by data in table. */
      , [Index Size] varchar(18)    /* Amount of space used by indexes in table. */
      , [Unused Space] varchar(18)   /* Amount of space reserved but not used. */
      ) ;
    go
    
    /*—————————————————————————*/
    /* Load the temp table                                                        */
    /*—————————————————————————*/
    declare @schemaname varchar(256) ;
    -- Make sure to set next line to the Schema name you want!
    set @schemaname = 'dbo' ;
    
    -- Create a cursor to cycle through the names of each table in the schema
    declare curSchemaTable cursor
      for select sys.schemas.name + '.' + sys.objects.name
          from    sys.objects
                , sys.schemas
          where   object_id > 100
                  and sys.schemas.name = @schemaname
                  /* For a specific table uncomment next line and supply name */
                  --and sys.objects.name = 'specific-table-name-here'    
                  and type_desc = 'USER_TABLE'
                  and sys.objects.schema_id = sys.schemas.schema_id ;
    
    open curSchemaTable ;
    declare @name varchar(256) ;  /* This holds the name of the current table*/
    
    -- Now loop thru the cursor, calling the sp_spaceused for each table
    fetch curSchemaTable into @name ;
    while ( @@FETCH_STATUS = 0 )
      begin    
        insert into #TableSizes
                exec sp_spaceused @objname = @name ;       
        fetch curSchemaTable into @name ;   
      end
    
    /* Important to both close and deallocate! */
    close curSchemaTable ;     
    deallocate curSchemaTable ;
    
    
    /*—————————————————————————*/
    /* Feed the results back                                                     */
    /*—————————————————————————*/
    select [Table Name]
          , [Number of Rows]
          , [Reserved Space]
          , [Data Space]
          , [Index Size]
          , [Unused Space]
    from    [#TableSizes]
    order by [Table Name] ;
    
    /*—————————————————————————*/
    /* Remove the temp table                                                     */
    /*—————————————————————————*/
    drop table #TableSizes ;
    

    taken from Robert Caine blog

    Edited the code to parse, several chars that were in single quote used a special single quote, as well the — sign.

    This code is for Microsoft SQL 2005+

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 358k
  • Answers 358k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It will depend on how you set up the project.… May 14, 2026 at 2:12 pm
  • Editorial Team
    Editorial Team added an answer You can do it numerically instead of usings strings: dateadd(day,… May 14, 2026 at 2:12 pm
  • Editorial Team
    Editorial Team added an answer It looks like my answer lies with the Mingw-w64 project… May 14, 2026 at 2:12 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.