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

In the Transact-SQL (T-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 T-SQL editor with a connection to a database server.

To connect to a different database in the same editor session

  • On the T-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 USEDatabaseName statement in your script or query.

Security

The Database list shows only those databases to which you have permission to connect.

See Also

Tasks

How to: Start the Transact-SQL Editor

How to: Disconnect from Databases

Other Resources

Script Analysis and Execution in the Transact-SQL Editor