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:
- 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:
If the connection is successful, you will see the following Object Explorer panel:
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.