Getting space back after manually deleting records

  • We have a database with lab tests that we are going to merge with a different database. The original has 8,000,000 records. The new one can only bring in 100,000 at a time. I am copying the database, then deleting down to 100,000 records. However, the space on disk remains the same. Do I need to pack the database somehow to regain the space ?

    Thanx !

  • chilidogie (10/16/2012)


    We have a database with lab tests that we are going to merge with a different database. The original has 8,000,000 records. The new one can only bring in 100,000 at a time. I am copying the database, then deleting down to 100,000 records. However, the space on disk remains the same. Do I need to pack the database somehow to regain the space ?

    Thanx !

    Yes. Rebuild the clustered index to recover the table space and rebuild the non-clustered indexes to regain the index space.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Thanx Greatly !!!!

  • If you want to release space on disk then you need to shrink the database. See DBCC SHRINKDATABASE. Beware, though - if your database is likely to grow again then you're wasting resources by shrinking it, as well as causing internal and external fragmentation.

    John

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply