Advertisement

04.17.2008 at 01:07PM PDT, ID: 23332377
[x]
Attachment Details

How do I release unused space from a single table in SQL Server?

Asked by neortho in SQL Server 2005, Databases Miscellaneous, MS SQL Server

Tags: Microsoft, SQL Server, 2005, Common methods didn't work. DB was restored from a backup made on SQL Server 2000

The production DB is on a SQL Server 2000 box, but all this was done on a backup that I restored to a SQL Server 2005 box.

I have a table that stores images (we'll call it img_table) that shows this when I run sp_spaceused:
Reserved:  105.7GB
Data: 8.4GB
Unused: 97.3GB
Index_Size: 40KB

Right now the DB's total size is 130GB.  If I could trim that down to 33 by cleaning up this table it might provide a nice performance increase or at the very least make maintenance less of a headache.

I spent several hours looking around Google and this site for a way to bring this down to a more manageable size.  I found a ton of different suggestions but none of them worked.  Here's what I've tried so far: (syntax might be a bit off, but I did eventually get all these to go through without errors)

I ran sp_help and noted that there was a clustered index for the table called PK_img_table since the table has a primary key.

I ran DBCC SHOWCONTIG (img_table,PK_img_table) and saw a lot of logical fragmentation in the index.

I ran DBCC INDEXDEFRAG (DBName, 'img_table', 'PK_img_table') and the index size went down to 40k from 800k, but the unused was pretty much unchanged.  DBCC SHOWCONTIG shows 0% logical fragmentation now.

So I ran DBCC DBREINDEX ('img_table', 'PK_img_table')  and not much happened.  I think the reserved, data, and unused went up or down by a few KB each.

Next I ran DBCC CLEANTABLE ('DBName', 'img_table') and again not much happened.

I tried dropping the index and recreating it, then going through all the above steps, but there's still 97GB of unused space.

I tried running a SHRINK command on the DB but the log file quickly filled up the disk.  I've thought about trying it again with recovery model on simple but haven't yet.

I thought about trying SELECT * INTO img_table2  FROM img_table and seeing if the copied table was smaller but I don't have enough free space on my drive for it.

Does anybody have any ideas, or is there a valid reason it should be acting like this?

Thanks in advance!
Start Free Trial
 
Loading Advertisement...
 
[+][-]04.17.2008 at 01:10PM PDT, ID: 21380845

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.17.2008 at 01:46PM PDT, ID: 21381189

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.17.2008 at 02:52PM PDT, ID: 21381736

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.17.2008 at 02:55PM PDT, ID: 21381758

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04.17.2008 at 07:52PM PDT, ID: 21382985

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.17.2008 at 08:05PM PDT, ID: 21383036

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.17.2008 at 08:05PM PDT, ID: 21383037

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.17.2008 at 08:13PM PDT, ID: 21383069

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.18.2008 at 11:35AM PDT, ID: 21388458

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.18.2008 at 01:23PM PDT, ID: 21389325

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2008 at 07:42AM PDT, ID: 21402319

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2008 at 07:53AM PDT, ID: 21402459

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2008 at 10:22PM PDT, ID: 21408252

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 11:44AM PDT, ID: 21423903

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 01:01PM PDT, ID: 21424731

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Server 2005, Databases Miscellaneous, MS SQL Server
Tags: Microsoft, SQL Server, 2005, Common methods didn't work. DB was restored from a backup made on SQL Server 2000
Sign Up Now!
Solution Provided By: mark_wills
Participating Experts: 4
Solution Grade: B
 
 
[+][-]04.24.2008 at 07:20AM PDT, ID: 21431108

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628