Solved

SQL Datasize on Table Large with 0 records in table

Posted on 2011-03-11
6
374 Views
Last Modified: 2012-06-27
I deleted all the rows in a table and the data size is still 7.5 gb.  Who do I release all that unused space.
SpacePic.jpg
0
Comment
Question by:rdray
6 Comments
 
LVL 28

Accepted Solution

by:
Ryan McCauley earned 500 total points
ID: 35112258
This happens when you DELETE records from a table - they're not actually deleted, just marked as deleted, and then overwritten later.

If you want to free up the space, issue this instead:

TRUNCATE TABLE dbo.SYSDATABASELOG

Open in new window


This will reset the high water mark on the table and free up the reserved space. You'll still have the space allocated in your data file, though - you'll need a DBCC SHRINKDB to free that up.
0
 
LVL 39

Expert Comment

by:lcohan
ID: 35112259
You could try DBCC UPDATEUSAGE on that table like below and check after that:

DBCC UPDATEUSAGE ('db_name','table_name')  -- WITH NO_INFOMSGS
0
 
LVL 32

Expert Comment

by:ewangoya
ID: 35112263

Try shrinking the database

Right click on the database, select Tasks->Shrink->Database

0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 39

Expert Comment

by:lcohan
ID: 35112320
Caution shrinking live on line databases even on SQL 2008.
0
 

Author Comment

by:rdray
ID: 35112633
All these are great.. I have done all of them with no change.
0
 
LVL 39

Expert Comment

by:lcohan
ID: 35112714
do you have a clustered index on it? if not try create one then drop, if yest try drop then re-create.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
TSQL DateADD update Question 4 40
create insert script based on records in a table 4 21
MS SQL Delete Query 9 33
PROPERCASE SCRIPT IN SQL 3 7
     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question