I dropped a database from SQL Server, however it turns out that my login was set to use the dropped database as its default. I can connect to SQL Server Man
I'll also prefer ALTER LOGIN
Command as in accepted answer and described here
But for GUI lover
Tired of reading!!! just look at following
Alternative to sp_defaultdb (which will be removed in a future version of Microsoft SQL Server) could be ALTER LOGIN:
ALTER LOGIN [my_user_name] WITH DEFAULT_DATABASE = [new_default_database]
Note: unlike the sp_defaultdb
solution user and database names are provided without quotes. Brackets are needed if name had special chars (most common example will be domain user which is domain\username
and won't work without brackets).
Click on options on the connect to Server dialog and on the Connection Properties, you can choose the database to connect to on startup. Its better to leave it default which will make master as default. Otherwise you might inadvertently run sql on a wrong database after connecting to a database.
To do it the GUI way, you need to go edit your login. One of its properties is the default database used for that login. You can find the list of logins under the Logins node under the Security node. Then select your login and right-click and pick Properties. Change the default database and your life will be better!
Note that someone with sysadmin privs needs to be able to login to do this or to run the query from the previous post.
In case you can't login to SQL Server:
sqlcmd –E -S InstanceName –d master
Reference: https://support.microsoft.com/en-us/kb/307864