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:
![](https://www.sqlservertutorial.net/wp-content/uploads/SSMS-connect-to-SQL-Server.png)
Step 2. Choose the Database Engine… from the Connect menu under the Object Explorer:
![](https://www.sqlservertutorial.net/wp-content/uploads/Open-the-Connection-Dialog-300x213.png)
Step 3. Enter the following information:
- Server Type: Database Engine
- Server name: localhost
- Authentication: SQL Server Authentication
- Login: sa
- Password: (The one you entered during the installation.)
- Check the Remember Password.
- Encryption: Optional
Click the Connect button to connect to the SQL Server:
![Connect to Local Server Server](https://www.sqlservertutorial.net/wp-content/uploads/Connect-to-Local-Server-Server.png)
If the connection is successful, you will see the following Object Explorer panel:
![Connect Microsoft SQL Server Management Studio](https://www.sqlservertutorial.net/wp-content/uploads/Connect-Microsoft-SQL-Server-Management-Studio.png)
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:
![](https://www.sqlservertutorial.net/wp-content/uploads/New-Query.png)
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:
![](https://www.sqlservertutorial.net/wp-content/uploads/SSMS-Execute-a-Query.png)
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.