title: Create a user for SQL Server 2008?
body: <p>I'm using this code to create a new user.</p>
  
  <pre><code>/****** Object:  User [primebox] ******/
  IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'primebox')
  CREATE USER [primebox] FOR LOGIN [primebox] WITH DEFAULT_SCHEMA=[primebox]
  GO
  </code></pre>
  
  <p>and I got the following error when I try to create this specific user.</p>
  
  <blockquote>
    <p><em>Msg 15007, Level 16, State 1, Line 1</em><br>
    <em>'primebox' is not a valid login or you do not have permission.</em></p>
  </blockquote>
  
  <p>The part that I don't understand is, I can create others users but this one in particular looks invalid</p>
  
  <p>I tried to rename my database and got this error</p>
  
  <blockquote>
    <p><em>Unable to rename primeboxs. (ObjectExplorer)</em></p>
    
    <p><em>Rename failed for Database 'primebox'.  (Microsoft.SqlServer.Smo)</em></p>
    
    <p><em>An exception occurred while executing a Transact-SQL statement or
    batch. (Microsoft.SqlServer.ConnectionInfo)</em></p>
    
    <p><em>The database could not be exclusively locked to perform the operation.
    (Microsoft SQL Server, Error: 5030)</em></p>
  </blockquote>
  
  <p>My guess is that the problem is the database name... but I got the code from another database (I'm creating a 'wanna be' backup) with the same user and database names. So I'm in a corner here... Any help will be a LOT appreciated =) </p>
  
  <p>PS: My computer name is box, windows 7. Using SQL Server 2008</p>