KB2967240 - FIX: Cannot reclaim unused space by using shrink operation in the table that contains a LOB column in SQL Server

Applies To
SQL Server 2008 Service Pack 3 SQL Server 2008 Developer SQL Server 2008 Enterprise SQL Server 2008 Standard SQL Server 2014 Developer - duplicate (do not use) SQL Server 2014 Enterprise - duplicate (do not use) SQL Server 2014 Standard - duplicate (do not use) SQL Server 2008 R2 Service Pack 2 SQL Server 2008 R2 Developer SQL Server 2008 R2 Enterprise SQL Server 2008 R2 Standard SQL Server 2012 Developer SQL Server 2012 Enterprise SQL Server 2012 Standard

Symptoms

Assume that you have a table that contains a large object (LOB) column in Microsoft SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, or SQL Server 2014. When you update the LOB column with smaller size of LOB data and try to reclaim the unused space by using the following methods:

  • DBCC SHRINKDATABASE / DBCC SHRINKFILE
  • ALTER INDEX REORGANIZE WITH (LOB_COMPACTION = ON)

In this situation, the unused space cannot be reclaimed.

Resolution

The issue was first fixed in the following cumulative update of SQL Server.

Cumulative Update 2 for SQL Server 2012 SP2 /en-us/help/2983175

Cumulative Update 11 for SQL Server 2012 SP1 /en-us/help/2975396

Cumulative Update 13 for SQL Server 2008 R2 SP2 /en-us/help/2967540

Cumulative Update 2 for SQL Server 2014 /en-us/help/2967546

Cumulative Update 17 for SQL Server 2008 SP3 /en-us/help/2958696

About cumulative updates for SQL Server

Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. Check out the latest cumulative updates for SQL Server:

      

Workaround

To work around this issue, use the following workarounds:

  • Export all the rows to a new table and move the rows back. This reorganizes the LOB data and release the unused space.
  • Use DBCC SHRINKFILE with EMPTYFILE option to move all the data to a newly added data file and then remove old data file. This reorganizes the LOB data there by releasing the unused space.

More Information

The following example shows you the unused space by using TSQL command sp_spaceused 'table_name' before and after you update the LOB column with smaller size of LOB data:
Before you update:

name rows reserved data index_size unused
table_name 1000 261072 KB 261056 KB 16 KB 0 KB

After you update:

name rows reserved data index_size unused
table_name 1000 261072 KB 199672 KB 16 KB 61384 KB

      

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.