SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Reclaim space after setting column to NULL
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Kimi86
Yak Posting Veteran

78 Posts

Posted - 03/01/2013 :  11:35:54  Show Profile  Reply with Quote
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??

Edited by - Kimi86 on 03/01/2013 11:43:13

James K
Flowing Fount of Yak Knowledge

3649 Posts

Posted - 03/01/2013 :  12:14:38  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 03/01/2013 :  13:10:42  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000