title: Database Keeps Going into Recovery Pending State
body: <p>I have a SQL server database that has been running perfectly fine on my machine for about 6 months, a couple days ago out of nowhere it was inaccessible (Pending Recovery). </p>
  
  <p>I did a bunch of Googling and have tried the following things to fix the issue but thus far restoring it from a previous backup is the only thing that seems to work.</p>
  
  <p>I have tried (From SMS and SQLCMD):</p>
  
  <ol>
  <li><code>ALTER DATABASE mydatabase SET EMERGENCY</code> </li>
  <li><code>ALTER DATABASE mydatabase set single_user</code> </li>
  <li><code>DBCC CHECKDB (mydatabase, REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS;</code> </li>
  <li><code>ALTER DATABASE mydatabase set multi_user</code></li>
  </ol>
  
  <p>Step #3 errors out with: "cannot open mydatabase is already open and can only have one user at a time"</p>
  
  <p>Second try:</p>
  
  <ol>
  <li><code>EXEC sp_resetstatus 'mydatabase';</code></li>
  <li><code>ALTER DATABASE mydatabase SET EMERGENCY</code></li>
  <li><code>DBCC CHECKDB ('mydatabase')</code></li>
  <li><code>ALTER DATABASE mydatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE</code></li>
  <li><code>DBCC CHECKDB ('mydatabase', REPAIR_ALLOW_DATA_LOSS)</code></li>
  <li><code>ALTER DATABASE mydatabase SET MULTI_USER</code></li>
  </ol>
  
  <p>Step #5 errors out with the same error.</p>
  
  <p>My question is what could be causing this in the first place and how can I fix it properly without having to do a restore twice a day.</p>