Share via


How to: Connect to a Database in the T-SQL Editor

Before you can execute your scripts and queries, you must first connect to a database. You can connect when you start the Transact-SQL (T-SQL) editor. If you disconnect from the database, you can also reconnect to the database. In both cases, the process is similar. The only difference is whether the Connect to Database dialog box appears automatically or whether you must take an action before the dialog box appears.

To connect to a database in the T-SQL editor

  1. On the Data menu, point to T-SQL Editor, point to New Query Connection, and click Connect.

    The Connect to Database dialog box appears.

    Note

    You can also click Connect on the T-SQL Editor toolbar.

  2. In the Connection list, click the database to which you want to connect. If that database is not available, click New Connection. For more information, see How to: Create a Database Connection.

  3. Click OK.

    A connection is established to the server and database that you specified.

Security

You must have permissions to access the server and database to which you are connecting or an error will occur when you try to connect.

See Also

Tasks

How to: Create a Database Connection
How to: Disconnect from Databases
How to: Connect to Different Databases in the Same Editor Session
How to: Start the Transact-SQL Editor