Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
Analytics Platform System (PDW)
SQL database in Microsoft Fabric
The sqlcmd utility lets you enter Transact-SQL statements, system procedures, and script files.
sqlcmd variants
There are two variants of sqlcmd:
sqlcmd (Go): The
go-mssqldb
-based sqlcmd, sometimes styled as go-sqlcmd. This version is a standalone tool you can download independently of SQL Server. It runs on Windows, macOS, Linux, and in containers.sqlcmd (ODBC): The platform-aligned, ODBC-based sqlcmd, available with SQL Server or the Microsoft Command Line Utilities, and part of the
mssql-tools
package on Linux. It also runs on Windows, macOS, Linux, and in containers.
Download and install sqlcmd (Go)
sqlcmd (Go) can be installed cross-platform, on Microsoft Windows, macOS, and Linux. Versions newer than 1.6 might not be available in all package managers. There's no estimated date yet for their availability.
winget (Windows Package Manager CLI)
Install the Windows Package Manager Client if you don't already have it.
Run the following command to install sqlcmd (Go).
winget install sqlcmd
Chocolatey
Install Chocolatey if you don't already have it.
Run the following command to install sqlcmd (Go).
choco install sqlcmd
Direct download
Download the corresponding
-windows-amd64.zip
or-windows-arm.zip
asset from the latest release of sqlcmd (Go) from the GitHub code repository.Extract the
sqlcmd.exe
file from the downloaded zip folder.
Download and install sqlcmd (ODBC)
sqlcmd (ODBC) can be installed cross-platform, on Microsoft Windows, macOS, and Linux.
Download the command line utilities for Windows, using the following table.
Driver | Platform |
---|---|
Microsoft Command Line Utilities 15 for SQL Server | x64 x86 |
The command line tools are General Availability (GA), however they are also released with the installer package for SQL Server 2019 (15.x) and later versions.
Version information
- Release number: 15.0.4298.1
- Build number: 15.0.4298.1
- Release date: April 7, 2023
Note
The sqlcmd download provided here might not have the same release and build number as sqlcmd installed with the latest SQL Server cumulative update (CU). This behavior is expected. This version contains all the fixes included in the latest CU.
sqlcmd (ODBC) supports authentication with Microsoft Entra ID, including multifactor authentication (MFA) support for Azure SQL Database, Azure Synapse Analytics, and Always Encrypted features.
System requirements
- Windows 10 and later versions
- Windows Server and later versions
This component requires both the built-in Windows Installer 5 and the Microsoft ODBC Driver 17 for SQL Server.
Preinstalled
You can also find sqlcmd preinstalled in certain environments.
Azure Cloud Shell
You can try the sqlcmd utility from Azure Cloud Shell, as it's preinstalled by default.
Azure Data Studio
To run SQLCMD statements in Azure Data Studio, select Enable SQLCMD from the editor toolbar.
SQL Server Management Studio (SSMS)
To run SQLCMD statements in SQL Server Management Studio (SSMS), navigate to Query > SQLCMD Mode.
SSMS uses the Microsoft .NET Framework SqlClient
for execution in regular and SQLCMD mode in Query Editor. When sqlcmd is run from the command-line, sqlcmd uses the ODBC driver. Because different default options could apply, you might see different behavior when you execute the same query in SSMS in SQLCMD mode and in the sqlcmd utility.