title: DBCC SHRINKFILE to truncate the transaction log
body: <p>I had some databases that would not truncate the transaction log.</p>
  
  <p>These databases are all in <strong>SIMPLE</strong> recovery mode, and we are ok with one full backup daily.</p>
  
  <p>First thing I checked is if there were some sort or open transactions or something preventing the logs to be re-used.</p>
  
  <pre><code>SELECT name, log_reuse_wait_desc
  FROM sys.databases
  WHERE log_reuse_wait &lt;&gt; 0
  </code></pre>
  
  <p>which gave me the following results:</p>
  
  <p><img src="https://i.stack.imgur.com/2QA9u.jpg" alt="two databases waiting for LOG BACKUP reuse"></p>
  
  <p>To get rid of the LOG_BACKUP, I did:</p>
  
  <pre><code>USE [master]
  GO
  ALTER DATABASE mydb SET RECOVERY BULK_LOGGED WITH NO_WAIT
  </code></pre>
  
  <p>and back to SIMPLE:</p>
  
  <pre><code>USE [master]
  GO
  ALTER DATABASE mydb SET RECOVERY SIMPLE WITH NO_WAIT
  </code></pre>
  
  <p>That sorted the LOG_BACKUP but I still had lack of disk space issues.</p>
  
  <p>So I desperately run the following command:</p>
  
  <pre><code>DBCC SHRINKFILE (N'wslogdb70_27_log', 0, TRUNCATEONLY)
  </code></pre>
  
  <p>I hope this TRUNCATED the transaction log, instead of SHRINKING it.</p>
  
  <ul>
  <li>Am I correct?</li>
  <li>Is there any article/book that references this?</li>
  </ul>