How to: Connect to Different Databases in the Same Editor Session

In the Transact-SQL editor, you can connect to a different database on the same server without closing your editing session. For example, you do not need to manually disconnect from a server and then reconnect to it every time that you query a different database on the same server.

To complete this procedure, you must have an active session of the Transact-SQL editor with a connection to a database server.

To connect to a different database in the same editor session

  • On the Transact-SQL Editor toolbar, in the Database list, click the name of the database to which you want to connect.

    Note

    You can also press CTRL+J to give focus to the Database list.

    When you click the database name, the editor connection is changed to use that database. The window name and the properties window both reflect the name of the database to which you are connected.

    Note

    You can also specify a different database by including a USE DatabaseName statement in your script or query.

Security

The Database list on the Transact-SQL Editor toolbar shows all databases present on the corresponding instance of SQL Server. Appropriate permissions are required to access each of those databases. For more information, see Lesson 2: Configuring Permissions on Database Objects.

See Also

Tasks

How to: Start the Transact-SQL Editor

How to: Disconnect from Databases

Concepts

Editing Database Scripts and Objects with the Transact-SQL Editor