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
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.
In the Server Name box, enter the name of the instance of SQL Server.
In the Authentication box, select Windows Authentication or SQL Server Authentication.
To use your Microsoft Windows credentials to log on to the server, click Windows Authentication.
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.
For additional connection options, click Options. For more information about these options, see Connect to Server (Connection Properties Page) Database Engine.
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