title: SQL Server 2008 R2 Stuck in Single User Mode
body: <p>Having executed a DB deploy (from a VS SQL Server database project) on a local database, which failed, the database has been left in a state where it has single user mode left on (the deploy runs as single user mode).  </p>
  
  <p>When I connect to it from SSMS and try something like the following:</p>
  
  <pre><code>ALTER DATABASE MyDatabase
  SET MULTI_USER;
  GO
  </code></pre>
  
  <p>I get the error:</p>
  
  <blockquote>
    <p>Changes to the state or options of database 'MyDatabase' cannot be made at this time. The database is in single-user mode, and a user is currently connected to it.</p>
  </blockquote>
  
  <p>I tried taking the database offline, which SSMS tells me succeeds, but it doesn't appear to actually do anything. So far, I've only been able to get around this by dropping and recreating the database (which is kind of okay, because it's only a local test database). However, I'd like to be able to reset the status.</p>
  
  <p>How can I convince SQL Server to take this database out of single user mode?</p>