title: SQL Server - Create a new database for a user and ONLY give them access / view rights to that one DB
body: <p>I have admin rights on a SQL Server 2012 Server and have a user that wants me to create a "throw away" database for them on the server.
  Basically, I'm looking to:</p>
  
  <ol>
  <li>Create this database</li>
  <li>Give the user full access / rights TO ONLY THAT DATABASE</li>
  <li>Have them see it and its schema - but not any other DBs - in the SSMS Object Explorer</li>
  </ol>
  
  <p>I've found quite a few answers around online and the one that got me closest was this one:
  <a href="https://stackoverflow.com/a/15400392/1693085">https://stackoverflow.com/a/15400392/1693085</a></p>
  
  <p>Basically giving me these lines of SQL to execute:</p>
  
  <pre><code>--Step 1: (create a new user)
  create LOGIN hello WITH PASSWORD='foo', CHECK_POLICY = OFF;
  
  
  -- Step 2:(deny view to any database)
  USE master;
  GO
  DENY VIEW ANY DATABASE TO hello; 
  
  
   -- step 3 (then authorized the user for that specific database , you have to use the  master by doing use master as below)
  USE master;
  GO
  ALTER AUTHORIZATION ON DATABASE::yourDB TO hello;
  GO
  </code></pre>
  
  <p>However, when I then log in as this user and right click on a created table, I get the following error repeated dozens of times:</p>
  
  <pre><code>An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
  
  ------------------------------
  ADDITIONAL INFORMATION:
  
  The EXECUTE permission was denied on the object 'xp_instance_regread', database 'mssqlsystemresource', schema 'sys'.
  </code></pre>
  
  <p>And, if I ignore it and try and delete the table anyways, I get basically the same error again.</p>
  
  <p>All I basically want to do is create a user and ensure they have no more access than that one database, but have full access on that one...</p>
  
  <p>Am I doing something wrong / What should I change??</p>
  
  <p>Thanks!!!</p>