Script to shrink log files

Hello,
has anyone a script that shrink huges log files in SQL Server 2012 environments?

Thanks a lot in advance.

Luis

http://blog.sqlauthority.com/2010/05/03/sql-server-shrinkfile-and-truncate-log-file-in-sql-server-2008/

The best way to shrink a log file is to set your database to simple recovery if it is not or use the below command:

ALTER DATABASE databasename SET RECOVERY SIMPLE
DBCC SHRINKFILE (databasename_Log, 1)

NO!!!! You lose your recovery points when you set it to SIMPLE. If there are completed transactions in the log that is preventing a shrink when using bulklogged or full recovery models, you simply just need to backup the transaction log. By doing it this way, you have not broken the transaction log chain.

1 Like