SQL Server 2008 R2 – How to Apply Changes and Truncate Large Log File

sql server

As a developer from time to time I will need to restore a local copy of our live database for testing purposes. I 'm running into disk space issues because the logs are bloody 15gb. I was told the transaction log is basically a log of the operations that were executed on that db and the db never actually updates. It simply reflects whats in the log.

If this is true then how can apply those changes mention in the log then truncate it so it's not 15gb

Best Answer

In order to stop your transaction log growth you need to take regular transaction log backups (along with full database backups).

If it is a test database and you don't need to recover it to a point in time in case of a disaster you can switch the database recovery model to SIMPLE (you probably are using FULL recovery because it is default in SQL Server).

Once you run regular log backups you can use DBCC SHRINKFILE to reduce the file size.

Please read the following question: Why Does the Transaction Log Keep Growing or Run Out of Space? - it provides you with a really good understanding of the problem.