title: ALTER DATABASE failed because a lock could not be placed on database
body: <p>I need to restart a database because some processes are not working. My plan is to take it offline and back online again.</p>
  
  <p>I am trying to do this in Sql Server Management Studio 2008:</p>
  
  <pre><code>use master;
  go
  alter database qcvalues
  set single_user
  with rollback immediate;
  alter database qcvalues
  set multi_user;
  go
  </code></pre>
  
  <p>I am getting these errors:</p>
  
  <pre><code>Msg 5061, Level 16, State 1, Line 1
  ALTER DATABASE failed because a lock could not be placed on database 'qcvalues'. Try again later.
  Msg 5069, Level 16, State 1, Line 1
  ALTER DATABASE statement failed.
  Msg 5061, Level 16, State 1, Line 4
  ALTER DATABASE failed because a lock could not be placed on database 'qcvalues'. Try again later.
  Msg 5069, Level 16, State 1, Line 4
  ALTER DATABASE statement failed.
  </code></pre>
  
  <p>What am I doing wrong?</p>