03. Connect to SQL Server instance

This article explains how to connect to SQL Server instance.

Connection Tools

SQL Server Management Studio(SSMS) or sqlcmd are commonly used to connect to SQL Server. SSMS is GUI tool and sqlcmd is CLI, so SSMS is easier to use for managing SQL Server operations.

SQL tools overview - SQL Server
SQL query and management tools for SQL Server, Azure SQL (Azure SQL database, Azure SQL managed instance, SQL virtual ma...


Download tools

SSMS can be downloaded from here.

Download SQL Server Management Studio (SSMS) - SQL Server Management Studio (SSMS)
Download the latest version of SQL Server Management Studio (SSMS) for managing and configuring instances of SQL Server ...

If you have already install SQL Server, sqlcmd tool is also installed in the same server. If you want to use sqlcmd on a server where SQL Server is not installed, you can download it from the following site.

SQL Command Prompt Utilities (Database Engine) - SQL Server
Command prompt utilities enable you to script SQL Server operations. This article lists many command prompt utilities th...


Install tool

Download “SSMS-Setup-{loc}.exe” and execute it.


Connect to SQL Server by SSMS

After installing SSMS, you can see SQL Server Management Studio in Windows menu. Launch the SQL Server Management Studio, then SQL Server connection screen will be displayed.


In the Server Name field, enter the hostname where SQL Server is installed. Additionally, change the Encryption field to “Optional.” If the Encryption field is set to “Mandatory”, encrypted connection will be enabled, which will result in a connection failure at this time.


When the connection to SQL Server is successful, the databases and other objects in SQL Server will be displayed in the Object Explorer panel.


Connect to SQL Server by sqlcmd

After successfully installing SQL Server, launch the Command Prompt. Then, execute the following command. This command is used to connect to SQL Server.

— command
sqlcmd -S hostName -E

If the text “1>” is displayed, the connection to SQL Server was successful. For example, to check the SQL Server version after connecting, execute the following query: