Edit

Share via


Check installed version of sqlcmd utility

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.

To determine your installed variant and version, run the following statement at the command line:

sqlcmd "-?"
sqlcmd "-?"
sqlcmd -?

sqlcmd (Go)

If you're using the new version of sqlcmd (Go), the output is similar to the following example:

Version: 1.8.2

You can use sqlcmd --version to determine which version is installed. You should have at least version 1.0.0 installed.

sqlcmd (ODBC)

If you're using sqlcmd (ODBC), the output is similar to the following example:

Microsoft (R) SQL Server Command Line Tool
Version 16.0.4025.1 NT
Copyright (C) 2022 Microsoft Corporation. All rights reserved.

You might have several versions of sqlcmd (ODBC) installed on your computer. Be sure you're using the correct version. You should have at least version 15.0.4298.1 installed.

Always Encrypted (-g) and Microsoft Entra authentication (-G) require at least version 13.1.

Remarks

Installing sqlcmd (Go) via a package manager replaces sqlcmd (ODBC) with sqlcmd (Go) in your environment path. You must close and reopen any current command line sessions for this change to take effect. sqlcmd (ODBC) isn't removed, and can still be used by specifying the full path to the executable.

You can also update your PATH variable to indicate which takes precedence. To do so in Windows 11, open System settings and go to About > Advanced system settings. When System Properties opens, select the Environment Variables button. In the lower half, under System variables, select Path and then select Edit. If the ___location sqlcmd (Go) is saved to (C:\Program Files\sqlcmd is default) is listed before C:\Program Files\Microsoft SQL Server\<version>\Tools\Binn, then sqlcmd (Go) is used. You can reverse the order to make sqlcmd (ODBC) the default again.