HowTo: Grow a very large MS-SQL Log File

Microsoft SQL Server 2005 has a nasty habit of creating thousands or hundreds of thousands of logical log files even though you set Autogrowth to a large size, say 8GB. The following SQL code automates manually growing your log file by 8GB increments. When using the ALTER DATABASE command to modify log file size manually like this, SQL Server seems to properly create logical log files of around 1GB each resulting in far less logical log files overall. This should increase log file performance.

This code assumes several things:
1) If your database has multiple log files, we will grow the most recently created log file.
2) You have backed up the database AND log file immediately prior to running this code.
3) If mirroring your database using SQL Mirroring that the principle and mirror databases are properly synchronized.

You will need to change 3 variables as noted in the comments at the top of the code; @DatabaseName, @BaseSize, and @TargetSize:
@DatabaseName is, rather obviously, the name of the database whose log file needs growing
@BaseSize is the current size of the logfile expressed in MB.
@TargetSize is the desired size of the logfile, again expressed in MB.

Note Well: This code is to be used only at your own risk, and comes with no warranties, guarantees or otherwise, express or implied.