Truncate MS SQL Database Log file

Submitted by Divya on

Large size of log file can be truncated using the below command. Make sure to take backup if log file is necessary. Replace the database name 'test' and log file name 'test_log' in the below below query then execute.

USE test
GO
ALTER DATABASE test SET RECOVERY SIMPLE WITH NO_WAIT
DBCC SHRINKFILE(test_log,1)
ALTER DATABASE test SET RECOVERY FULL WITH NO_WAIT
GO