Sql-server – move blob data to new filegroup

sql serversql-server-2008

short version: what options do i have to move a table that has blob data over to a new filegroup, without blowing out the txlog?

details:
we have an extremely over-allocated filegroup ("DA1"). the plan is: move all the objects to a new (right-sized) filegroup("DA2"), shrink/delete DA1 to reclaim all that disk space*. Easy, right? So, I already moved most all the objects to DA2, most all were pretty small. This last table has blob data, it's about 250GB. prod is in FULL recovery. What we've tried in dev: 1) tried a shrink, took over 11 hours before we killed it. 2) i tried SELECT INTO a new table on DA2 so I could delete&rename, however, the log grew too large and consumed the log drive (constraints here too 🙁 I do have large maintenance windows on the weekends, but cannot change the recovery model. Any other ideas I can test out?

*we're talking about 2TB to reclaim, and thus has created problems/pressure on restoring this db to lower environments because it's just_too_big.

Best Answer

You can try moving the data by rebuilding indexes. There are some limitations to this, for example, your clustered index rebuild will have to be done OFFLINE (a limitation of ONLINE rebuilds) and any non-clustered indexes can be rebuilt online as long as the LOB data is not part of the index key or as an include column.

Also, during the index build operation, the transaction log can be backed up and truncated, provided you do not run the index operation in an explicit transaction.

Microsoft has a guide on calculating the space required for here. They also have some general recommendations such as switching to BULK-LOGGED recovery to reduce the amount of transaction log data. See here for guidelines from Microsoft.

One of the advantages to this is you can move an index at a time, so you can do this over multiple maintenance windows if need be.