Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Enterprise
Expertise: All
Jul 28, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Change Database Connection in SQL Server

In general, every user tends to work on a separate database on the server during the development phase of an application. It can be annoying for users to repeatedly change the default database to the one to which they are connected when logging on to SQL Server. You can change the database connection using the stored procedure sp_defaultdb:

sp_defaultdb login_id, defaultdb

After sp_defaultdb is executed, users are connected to the new defaultdb the next time they log in. However, this stored procedure does not automatically give users access to that database. The database owner must explicitly give access to the users. If no default database has been specified, users are connected to the master database. Execute permission for this procedure defaults to public for a user's login ID only and to the system administrator for any login ID.

Jai Bardhan
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date