sqlcmd is a cross-platform command-line database utility developed by Microsoft for interacting with SQL Server and Azure SQL environments. Written in Go, it uses the go-mssqldb driver rather than the traditional ODBC implementation. Users can execute Transact-SQL queries interactively, process SQL script files, or accept piped input for automation. Integrated commands create and manage local SQL Server instances through compatible container runtimes. Persistent connection contexts simplify switching between database servers and authentication configurations. Microsoft Entra ID integration supports interactive authentication, managed identities, and service principals. Configurable output formats include traditional horizontal results, vertical layouts, and ASCII tables. sqlcmd supports Windows, macOS, and Linux.
Features
- Cross-platform SQL Server and Azure SQL database connectivity through the native Go database driver
- Interactive Transact-SQL execution with batch processing, script file support, and piped command input
- Automated local SQL Server instance provisioning through Docker and Podman container runtimes
- Persistent database connection contexts with configurable YAML files and generated connection strings
- Microsoft Entra ID authentication supporting interactive sessions, managed identities, and service principals
- Customizable query result formatting with ASCII tables, vertical layouts, console coloring, and driver diagnostic logging