In SSMS whenever we connect to any database server by default the MASTER database is the default selected one. Which forces us in changing the database the one we want work using the USE statement or by using mouse and changing the selected db from the drop-down list.This is were anoying, and till recently daily I was wasting time in doing this multiple times.
If we know that by default most of the time we will be connecting to a specific database related to our project, then Sql Server Management Studio (SSMS) provides a way to change this. And next time onwards this nerw selected database will selected by default instead of the MASTER DB.
Steps: 1) Open Sql Server Management Studio
2) Go to object Explorer -> Security -> Logins
3) Right click on the login and select properties
4) And in the properties window change the default database and click OK.
Alternatively, we can change this by below statement aswell:
Exec sp_defaultdb@loginame='TestUser', @defdb='Test'
Note: Please don’t experiment this on production database and also User should have access to the database to which we are changing.
Please correct me, if my understanding is wrong. Comments are always welcome.