Connect to the SQL Server

Summary: in this tutorial, you will learn how to connect to SQL Server from the SQL Server Management Studio and execute a query.

Connect to the SQL Server using SSMS

To connect to the SQL Server using the Microsoft SQL Server Management Studio, follow these steps:

Step 1. Launch the Microsoft SQL Server Management Studio:

Step 2. Choose the Database Engine  from the Connect menu under the Object Explorer:

Step 3. Enter the following information:

  1. Server Type: Database Engine
  2. Server name: localhost
  3. Authentication: SQL Server Authentication
  4. Login: sa
  5. Password: (The one you entered during the installation.)
  6. Check the Remember Password.
  7. Encryption: Optional

Click the Connect button to connect to the SQL Server:

Connect to Local Server Server

If the connection is successful, you will see the following Object Explorer panel:

Connect Microsoft SQL Server Management Studio

Execute a query

To execute a query you follow these steps:

First, right-click on the localhost (SQL Server …) node and choose the New Query menu item:

Second, enter the following query in the Editor

select @@version;Code language: SQL (Structured Query Language) (sql)

This query returns the version of the SQL Server.

Third, click the Execute button:

The Results window shows the version of the SQL Server as shown in the above screenshot. A quick way to execute a query is to press the F5 keyboard shortcut.

Now, you should know how to connect to an SQL Server and execute a query from the SSMS.

Was this tutorial helpful?