SQL 2000: Truncating a transaction log

With appropriate db backups and regular system maintenance in place, your transaction logs will usually remain a reasonable size.

For whatever reason, though, your logs are growing and you need to cut them down to size. (Perhaps jobs were failing due to running out of space, or for whatever other reason)

First, it's usually a good idea to make sure that a current good backup of the db your dealing with has been made -- after all, recovery is usually why we rely on transaction logs.

Once the db is backed up, you can:
  • execute "BACKUP LOG databaseName WITH TRUNCATE_ONLY" using Enterprise Manager or Query Analyzer
  • to recover the space that this will free, you then either:
  • run "DBCC SHRINKFILE (filename, size )" where is the filename without the ldf extension, and size is the target size for the file
  • use the shrink database functionality through Enterprise Manager (right click the db name -> All Tasks -> Shrink Database... -> Click "Files" button, and select the logfile from the dropdown, select the desired "Shrink action" and click "Ok" -> A dialog box should pop up when the shrinking has completed -> Clear the dialog box and cancel out of the "Shrink Database" window, otherwise you may shrink more than you'd bargained for)
Refresh your view of the DB (Right click in Ent. Mgr. -> Refresh), and you should see that space has been freed, if the file was successfully shrunk.