Skip to content

Instantly share code, notes, and snippets.

@jikuja
Created February 6, 2022 16:17
Show Gist options
  • Save jikuja/179d38a636e1cac871f361e6182e79f8 to your computer and use it in GitHub Desktop.
Save jikuja/179d38a636e1cac871f361e6182e79f8 to your computer and use it in GitHub Desktop.
sqlcmd cross-platform mess
# Sqlcmd
Sqlcmd is a simple tool for SQL Server automation
## The mess
### Missing features on Windows
Access token based Azure AD authentication is not supported:
Linux/Mac version documentation(https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/connecting-with-sqlcmd?view=sql-server-ver15) has following statement:
> Specify a user password. When used with the -G option without -U, specifies a file that contains an access token (v17.8+). The token file should be in UTF-16LE (no BOM) format.
Windows version documentation has not mentions about access token: https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-ver15
### Missing features on Linux/Mac
No support for sqlcmd scripting variable although some sources states that sqlcmd is able to pick values for variables from enviroment variables: https://stackoverflow.com/questions/11668193/using-variables-in-sqlcmd-for-linux
### Invoke-Sqlcmd Cmdlet
Invoke-Sqlcmd Powershell Cmdlet seems to support access token on Windows.
TODO: test access token on linux
TODO: test scripting variables on linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment