id = "sqlcmd"
name = "sqlcmd"
homepage = "https://github.com/microsoft/go-sqlcmd"
description = "Microsoft's command-line tool for querying and managing SQL Server."
executables = ["sqlcmd"]
[dotfiles]
paths = []
secret = ["~/.sqlcmd/sqlconfig"]
side_effect = false
[commands]
format = 1
label = "Run SQL Server queries"
description = "Connect to SQL Server with sqlcmd and run a query or script file, or open the interactive prompt. Passwords (-P) are left out so they do not land in shell history; contexts and the modern subcommands are not covered."
quality = "ai-draft"
parser = { end_of_options = "--", interleave = "permute", long_equals = false, short_attached = false, short_bundles = false }
[[commands.source]]
id = "docs"
kind = "manual"
url = "https://learn.microsoft.com/en-us/sql/tools/sqlcmd/sqlcmd-utility"
revision = "2026-10-27"
evidence = '''
-d db_name
Issues a USE <db_name> statement when you start sqlcmd.
-E
Uses a trusted connection instead of using a user name and password to sign in to SQL Server.
-G
Use this option to authenticate with Microsoft Entra when connecting to Azure SQL Database or Azure Synapse Analytics.
-S [protocol:]server[\instance_name][,port]
-U login_id
-i input_file[,input_file2...]
Identifies the file that contains a batch of Transact-SQL statements or stored procedures.
-o output_file
Identifies the file that receives output from sqlcmd.
-Q "cmdline query"
Executes a query when sqlcmd starts and then immediately exits sqlcmd.
-C
Use this option to configure the client to implicitly trust the server certificate without validation.
-b
Specifies that sqlcmd exits and returns a DOS ERRORLEVEL value when an error occurs.
-W
Removes trailing spaces from a column.
-s col_separator
Specifies the column-separator character.
'''
[[commands.field]]
id = "server"
label = "Server"
description = "[protocol:]server[\\instance][,port]"
type = "string"
option = ["-S"]
sources = ["docs"]
[[commands.field]]
id = "database"
label = "Database"
type = "string"
option = ["-d"]
sources = ["docs"]
[[commands.field]]
id = "user"
label = "Login"
type = "string"
option = ["-U"]
sources = ["docs"]
[[commands.field]]
id = "trusted"
label = "Trusted connection"
type = "boolean"
option = ["-E"]
sources = ["docs"]
[[commands.field]]
id = "entra"
label = "Microsoft Entra authentication"
type = "boolean"
option = ["-G"]
sources = ["docs"]
[[commands.field]]
id = "trust_cert"
label = "Trust server certificate"
description = "Skips certificate validation."
type = "boolean"
option = ["-C"]
sources = ["docs"]
[[commands.field]]
id = "query"
label = "Query (run and exit)"
type = "string"
option = ["-Q"]
sources = ["docs"]
[[commands.field]]
id = "input_file"
label = "Script file(s)"
description = "Comma-separated list without spaces."
type = "path"
option = ["-i"]
path = { kind = "file", role = "input", must_exist = true }
sources = ["docs"]
[[commands.field]]
id = "output_file"
label = "Output file"
type = "path"
option = ["-o"]
path = { kind = "file", role = "output" }
sources = ["docs"]
[[commands.field]]
id = "exit_on_error"
label = "Exit on error"
type = "boolean"
option = ["-b"]
sources = ["docs"]
[[commands.field]]
id = "trim"
label = "Trim trailing spaces"
type = "boolean"
option = ["-W"]
sources = ["docs"]
[[commands.field]]
id = "separator"
label = "Column separator"
type = "string"
option = ["-s"]
sources = ["docs"]
[[commands.task]]
id = "query"
label = "Run one query"
fields = ["server", "database", "trusted", "user", "query", "exit_on_error"]
required = ["server", "query"]
[[commands.task]]
id = "script"
label = "Run a script file"
fields = ["server", "database", "trusted", "user", "input_file", "output_file", "exit_on_error"]
required = ["server", "input_file"]
[[commands.group]]
id = "basic"
label = "Basic"
fields = ["server", "database", "user", "trusted", "query", "input_file"]
[[commands.group]]
id = "advanced"
label = "Advanced"
fields = ["entra", "trust_cert", "output_file", "exit_on_error", "trim", "separator"]