Like "Nikita" suggested, you could just change the recovery model to simple, so that changes are not tracked in the transaction log... However, if this is a production database, it is likely that you have log shipping in play, or ???, which requires the transaction log to be used to replicate changes to another server... If that's the case, then you need to understand what's causing the transaction log to fill up, and how to remedy it without disabling the trans log.
It sounds like you are using SSMS to do the changes, and the nature of the changes requires SSMS to:
- Delete all foreign keys, indexes, etc., from the changed table
- Copy all the data from the table to a #temp table
- Create a new table with the proposed changes
- Copy all the data from the #temp table to the newly created table
- Drop the old table
- Rename the new table to the old table's name
- Recreate all the indexes, foreign keys, etc.
The SSMS script inserts BEGIN TRANSACTION
and COMMIT TRANSACTION
throughout the script so that if something fails, hopefully your table and data will not be ruined. But since it also inserts GO
throughout the script, it is possible that an error will cause problems, especially since one of the last things it does it drop the original table and then rename the newly created table to the original table name.
It sounds like the transaction log fills up before the script finishes running. If you can't change your production database to a simple recovery model (e.g., because it will break log shipping, etc.), then you need to approach running the script in a way that won't fill up the transaction log.
I recommend:
- Build and test the script on a dev / test server first that doesn't have 1.5 million rows, to ensure that the script does exactly what you want it to do.
- Modify the script and add
COMMIT
in key places so that the space in the transaction log can be reclaimed as the script continues to run.
- Copy 100,000 records at a time from the #temp table back to the newly created table with a
COMMIT
between each block.
- Test the modified script again on a dev / test server before running it on production.
- Backup your production database before you run the script...