Truncate MS SQL Database Log file

1 post / 0 new
#1 20 April, 2017 - 18:35
Divya
Divya's picture

Truncate MS SQL Database Log file

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.
  1. USE test
  2. GO
  3. ALTER DATABASE test SET RECOVERY SIMPLE WITH NO_WAIT
  4. DBCC SHRINKFILE(test_log,1)
  5. ALTER DATABASE test SET RECOVERY FULL WITH NO_WAIT
  6. GO