How to: Connect to a Database in the Transact-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 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 Engine dialog box appears automatically or whether you must take an action before the dialog box appears.

To connect to a database in the Transact-SQL editor

  1. On the Data menu, point to Transact-SQL Editor, point to Connection, and click Connect. You can also click Connect on the Transact-SQL Editor toolbar. The Connect to Database Engine dialog box appears.

  2. In the Server Name box, enter the name of the instance of SQL Server.

  3. In the Authentication box, select Windows Authentication or SQL Server Authentication.

    1. To use your Microsoft Windows credentials to log on to the server, click Windows Authentication.

    2. To use SQL Server Authentication to log on to the server, select SQL Server Authentication, and then type your user name and password in User name and Password boxes.

  4. For additional connection options, click Options. For more information about these options, see Connect to Server (Connection Properties Page) Database Engine.

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

Security

You must have the appropriate permissions in order to access the server to which you are connecting or an error will occur when you try to connect. For more information about configuring the appropriate permissions, see Lesson 2: Configuring Permissions on Database Objects.

See Also

Tasks

How to: Disconnect from Databases

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

How to: Start the Transact-SQL Editor

Other Resources

How to: Create a Database Connection