| title | Download and Install the sqlcmd Utility | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| description | Learn how to download, install, or find the sqlcmd utility preinstalled on your system. | ||||||||||||||||
| author | dlevy-msft | ||||||||||||||||
| ms.author | dlevy | ||||||||||||||||
| ms.reviewer | randolphwest | ||||||||||||||||
| ms.date | 08/27/2025 | ||||||||||||||||
| ms.service | sql | ||||||||||||||||
| ms.subservice | tools-other | ||||||||||||||||
| ms.topic | conceptual | ||||||||||||||||
| ms.collection |
|
||||||||||||||||
| ms.custom |
|
||||||||||||||||
| helpviewer_keywords |
|
||||||||||||||||
| monikerRange | >=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =fabric-sqldb |
[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics PDW FabricSQLDB]
The sqlcmd utility lets you enter Transact-SQL statements, system procedures, and script files.
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 [!INCLUDE ssnoversion-md]. It runs on Windows, macOS, Linux, and in containers. -
sqlcmd (ODBC): The platform-aligned, ODBC-based sqlcmd, available with [!INCLUDE ssnoversion-md] or the Microsoft Command Line Utilities, and part of the
mssql-toolspackage on Linux. It also runs on Windows, macOS, Linux, and in containers.
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.
Choose one of the following options to install sqlcmd (Go) on Windows.
-
Install the Windows Package Manager Client if you don't already have it.
-
Run the following command to install sqlcmd (Go).
winget install sqlcmd
-
Install Chocolatey if you don't already have it.
-
Run the following command to install sqlcmd (Go).
choco install sqlcmd
-
Download the corresponding
-windows-amd64.zipor-windows-arm.zipasset from the latest release of sqlcmd (Go) from the GitHub code repository. -
Extract the
sqlcmd.exefile from the downloaded zip folder.
Choose one of the following options to install sqlcmd (Go) on macOS.
-
Install Homebrew if you need to.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -
Install sqlcmd with Homebrew.
brew install sqlcmd
-
Download the
-darwin-amd64.zipasset from the latest release of sqlcmd (Go) from the GitHub code repository. -
Extract the
sqlcmdfile from the downloaded zip folder.
Choose one of the following options to install sqlcmd (Go) on Linux.
-
Import the public repository GPG keys.
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc -
Add the Microsoft repository, where the
ubuntu/20.04segment might bedebian/11,ubuntu/20.04, orubuntu/22.04.add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/prod.list)" -
Install sqlcmd (Go) with apt.
apt-get update apt-get install sqlcmd
-
Import the Microsoft repository key.
rpm --import https://packages.microsoft.com/keys/microsoft.asc
-
Download the repository configuration file, where the
fedora/32segment might beopensuse/42.3,rhel/8, orsles/15. If the version of your OS doesn't directly correspond to one of those options, you might be able to use a repository configuration file from a version.curl -o /etc/yum.repos.d/packages-microsoft-com-prod.repo https://packages.microsoft.com/config/fedora/40/prod.repo
-
Install sqlcmd (Go) with yum.
yum install sqlcmd
-
Download the corresponding
-linux-x64.tar.bz2or-linux-arm.tar.bz2asset from the latest release of sqlcmd (Go) from the GitHub code repository. -
Extract the
sqlcmdfile from the downloaded zip folder.
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 [!INCLUDE sql-server-2019] and later versions.
- 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.
- Windows 10 and later versions
- Windows Server 2016 and later versions
This component requires the latest Microsoft ODBC Driver 17 for SQL Server.
See Install the sqlcmd and bcp SQL Server command-line tools on Linux for instructions to install sqlcmd on macOS.
See Install the sqlcmd and bcp SQL Server command-line tools on Linux for instructions to install sqlcmd on macOS.
You can also find sqlcmd preinstalled in certain environments.
You can try the sqlcmd utility from Azure Cloud Shell, as it's preinstalled by default.
To run SQLCMD statements in SQL Server Management Studio (SSMS), navigate to Query > SQLCMD Mode.
SSMS uses the Microsoft [!INCLUDE dnprdnshort-md] 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.