Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my desktop and on most other instances of Sql Server 2008 R2 and 2012, the default behavior when you right click on a database in the solution explorer of SSMS and choose "New Query" is a new query window opens and changes the database context to the database you clicked on. If you click new query button from the query window, it will open a new query from the same database. However, on some other machines, including my boss', the new query opens but the context is the default database (master by default). Clicking new query will likewise open a query in the default database. What is the option to make his instance act like mine?

If I connect to his database from my ssms, it still behaves like it does on his machine (incorrectly).

share|improve this question
I assume your boss can USE xxx where xxx is the database he'd like to query? – Max Vernon Sep 3 '13 at 22:07
Which version(s) of Management Studio are involved? (Is that what you mean when you say "instances of Sql"?) – Jon Seigel Sep 3 '13 at 22:12
@MaxVernon - that is true but involves another step. – DaveLib Sep 3 '13 at 22:25
I only asked that to eliminate user rights as a potential issue. Clearly you want to avoid the user manually selecting the database or typing USE xxx. What version of SSMS is installed on your desktop and his desktop? When you connect from your machine (and it doesn't work) are you using his logon, or yours? If you logon using your logon on his desktop, does it work? – Max Vernon Sep 3 '13 at 22:28
You could use a server-side trace to look for errors that occur at the time of hitting the "New Query" command. That should tell you if there is some server-side issue (or difference) between your logon and his. – Max Vernon Sep 3 '13 at 22:29

Max Vernon's suggestion about scripting the logons is spot on. For generic Windows Authentication, the default database tends to be master. Setting a default database for each database instance/logon combination will allow control over what the default database is when launching a new query editor window in SSMS.

If you use master for windows auth and/or administer many SQL Databases, the CTRL+U shortcut from a new query window -> select database -> hit enter to select and return to query editor will become firmly ingrained in motor memory.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.