Sunday, May 10, 2009

MS SQL Server: Default database for Windows user

Never ever set custom database as a default for your Windows account. If you drop the DB (quite legitimate operation when updating or scripting it), you will be kicked out of your Server Management Studio session to never come back (not quite true - you still can sneak in but why would you loose few precious nerve cells?)

If you are the same unfortunate idiot as I am - there is a way to fix this. You can do all kind of voodoo stuff from the command line and shell but if you prefer UI, then the first challenge will be to log in to the SQL Management Studio, unless you have a spare admin account at your disposal.

1. Click "Options" button and change database to connect to (because you just deleted your default one).
2. Run the following statement: ALTER LOGIN [server\account] WITH DEFAULT_DATABASE = master
Now your account has a mastr DB as your default (how it was supposed to be from the very beginning).

No comments:

© 2008-2013 Michael Goldobin. All rights reserved