title: restore sql server from .bak file Exclusive access could not be obtained
body: <p>I am trying to restore my sql using bak file</p>
  
  <p>I am getting error </p>
  
  <p>Exclusive access could not be obtained because the database is in use</p>
  
  <p>I tried </p>
  
  <pre><code>USE [master]
  ALTER DATABASE myDB
  SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  </code></pre>
  
  <p>and run the query</p>
  
  <pre><code>USE [master] RESTORE DATABASE  myDB
     FROM DISK = 'C:\MyDatabase.bak' WITH  FILE = 1,  NOUNLOAD,  STATS = 10
  </code></pre>
  
  <p>I also tried from restore wizard with same result.</p>
  
  <p>Exclusive access could not be obtained because the database is in use.</p>