Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Reclaim space after setting column to NULL

Author  Topic 

Kimi86
Yak Posting Veteran

79 Posts

Posted - 2013-03-01 : 11:35:54
I have a table with a varchar column that stores XML and consumes too much space..Hence I want to Set All XML fields to NULL and put those XMLs in another TAble. I dont want to drop the entire column since only 40 percent of the rows have XML while other have some other text stored in it.My problem Is when I set the XML fields to NULL the space occupied by the table does not change at all. I have tried DBCC CLEANTABLE but tat dint help..Also I dont want to copy the table into another table and rename it since the table is tooo heavy ..
Any Idea??

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-03-01 : 12:14:38
The documentation seems to indicate that CLEANTABLE will reclaim space only for dropped columns: http://msdn.microsoft.com/en-us/library/ms174418.aspx

You might want to try sp_spaceused with updateusage = 'TRUE' http://msdn.microsoft.com/en-us/library/ms188776.aspx
or DBCC UPDATEUSAGE http://msdn.microsoft.com/en-us/library/ms188414.aspx

I don't have any personal experience with either of these, so I have no constructive comments to add.
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2013-03-01 : 13:10:42
I assume you mean that the MDF file didn't shrink? If so, SQL is not going to give up any space willingly. If you want to reclaim that disk space you'll have to shrink the database (if do decide to shrink your DB, read up on how to do it properly). You might try rebuilding the indexes and see if that helps.

Also after running CLEANTABLE did you run UPDATEUSAGE?
Go to Top of Page
   

- Advertisement -