devxlogo

Change Database Connection in SQL Server

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.

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist