SQL Server how to get around the transaction log filling up when updating a column to an int
There's no way to tell SQL Server not to use the transaction log.
What you can do is set the recovery model of the database to SIMPLE, which will overwrite old log entries as space is needed. You should not do this on your production server, however, because you won't be able to do certain types of restores, such as point-in-time restores.
Alternatively, you can set your transaction log file to be larger -- as an unscientific rule of thumb I'd make sure that either A) your transaction log has at least about 1.5x more free space than the size of your table or B) that your transaction log can auto-grow to a drive which has at least about this amount of disk space free.
You can free transaction log space by backing up the log. If you don't care about the log contents, throw the file away. A shortcut for this is
BACKUP LOG <Your Database Name> TO DISK = 'NUL:'. Again, don't do this on a production server unless you are absolutely sure you understand the implications.
Another thing to be careful of (though it's not entirely germane to your question) is to make sure the table you're expanding has a clustered index defined on it. If it does not, the table could incur a very large amount of heap fragmentation, and potentially become needlessly large on a change like this.
- Drop any foreign keys
- Create new tables with
- Move the rows over per batch of 1000 (insert them in the new table, delete them from the old one)
- Drop the old tables
- Rename the new tables to the old names using
- Recreate the foreign keys
p.S. If your transaction log is large... check your recovery model. If your recovery model is not
simple, how long was it since you last backed up the log?