title: SQL Server Default Database when Query - master
body: <p>I've been using SQL Server Management Studio (SSMS) for the last 8 years, and I keep on stumbling upon a problem. When I right click on a Table, and select SELECT TOP 2000 ROWS, the query editor opens up a new file with the query inside. This is nice and all for a quick review of the table.</p>
  
  <p>The problem I have is the default database is changed from the actual database to the master database. I have sysadmin rights.</p>
  
  <p>The query that gets generated by SSMS, then has the databse, schema, and table in brackets, i.e. [DB].[dbo].[TableName]</p>
  
  <p>Is there a way to set the default database on the SELECT TOP 2000 ROWS command, to NOT go and set the default database to 'master' ?</p>
  
  <p>The other workaround is to click on the table, and then do a 'New Query', which will keep the current database, and then I have to type in 'SELECT * FROM TableName'</p>
  
  <p><img src="https://i.stack.imgur.com/4qceQ.png" alt="default database changed to master"></p>