I had a similar problem and I went with a modified # 3 approach. In my case, the database was in SIMPLE recovery mode, and no FK restrictions were referenced in the table to which the column was to be added.
Instead of creating a new table with the same schema and copying the contents of the original table, I used the SELECT ... INTO syntax.
According to Microsoft ( http://technet.microsoft.com/en-us/library/ms188029(v=sql.105).aspx )
The scope of the logging for SELECT ... INTO depends on the actual recovery model for the database. As part of a simple recovery model or volumetric recovery model, volumetric operations are minimally recorded. With minimal logging, using a SELECT ... INTO statement can be more than creating a table and then populating the table with an INSERT statement. For more information, see Transactions that may be Minimum Registered.
Sequence of steps:
1. Move data from the old table to the new one by adding a new column with a default value
SELECT table.*, cast ('default' as nvarchar(256)) new_column INTO table_copy FROM table
2.Wrap the old table
DROP TABLE table
3. Register the newly created table
EXEC sp_rename 'table_copy', 'table'
4. Creation of necessary restrictions and indexes in a new table
In my case, the table had more than 100 million rows, and this approach ended faster than approach No. 2, and the growth of journal space was minimal.
Tanya Kogan Oct 02 '13 at 15:59 2013-10-02 15:59
source share