... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)


Shrinking SQL Server Log Files

In SQL Server, the transaction log files grow unboundedly until you take some action.  To completely discard old transactions, perform the following steps in the database in question:

backup log databaseName to disk='nul:'
dbcc shrinkfile('logical log file name', 64)

If you actually want to save the contents of the transaction log, use a better pathname than nul.  If you do not know the logical log file name, execute this query:

select * from sys.database_files

In practice, I have found that you may have to run the BACKUP LOG command a few times to get the file to shrink down significantly.

Blog Archive