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, you use these steps:

First, launch the Microsoft SQL Server Management Studio from the Start menu:

Next, from the Connect menu under the Object Explorer, choose the Database Engine 

Then, enter the information for the Server name (localhost), Authentication (SQL Server Authentication), and password for the  sa user and click the Connect button to connect to the SQL Server. Note that you should use the sa user and password that you entered during the installation.

If the connection is established successfully, then 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 a SQL Server and execute a query from the SSMS.

Was this tutorial helpful?