title: Why does DBCC SHRINKFILE work inconsistently in a database job?
body: <p><code>DBCC SHRINKFILE</code> always works when I run it manually on a log file, even when I get the following message:</p>
  
  <pre><code>'Cannot shrink log file 2 (Claim_Log) because all logical log files are in use.'
  </code></pre>
  
  <p>When I run it from a job, however, it only shrinks the log about one third of the time. The other times, it just remains large (about 150Gb). There is never any error other than the one listed above. This is the statement that I use:</p>
  
  <pre><code>DBCC SHRINKFILE (N'Claim_log' , 0, TRUNCATEONLY)
  </code></pre>
  
  <p>I have "Include step output in history" enabled on the job step. Is there something else I can do to get more information on why this isn't working?</p>
  
  <p>Edit:
  Here is the full message from the log:</p>
  
  <pre><code>'Executed as user: *. Cannot shrink log file 2 (Claim_Log) because all logical
  log files are in use. [SQLSTATE 01000] (Message 9008)  DBCC execution completed. 
  If DBCC printed error messages, contact your system administrator. [SQLSTATE 01000]
  (Message 2528).  The step succeeded.'
  </code></pre>
  
  <p>I have already tried kicking users out of the db and setting it to single user mode.</p>