TigerQuery is a lightweight SQL script engine and parser with familiar
sqlcmd and SSMS SqlCmd-mode scripting, plus SqlCmdEx: an extended mode
for applications and automation that protects host-provided variables from
script-level :setvar overrides.
It powers tiger-sqlcmd, a modern CLI for executing complex .sql scripts with
repeatable batches, variable injection, and advanced scripting features. TigerSqlCmd
follows TigerCli's One Command Model, Multiple Interaction Modes: the same commands
serve normal semi-interactive execution and automation-safe --non-interactive
execution for scripts, CI, scheduled jobs, redirected runs, and coding agents.
TigerQuery is actively developed and remains pre-1.0. It is well tested, used in real SQL Server automation and end-to-end workflows, and suitable for practical use today. Pre-1.0 releases can still evolve; compatibility differences and current limitations are documented explicitly and protected by tests.
tiger-sqlcmd is a first-class .NET tool for people and automation that need to run
SQL Server scripts, reuse saved connection profiles, and get predictable diagnostics
and exit codes without embedding a library. TigerQuery provides its SQLCMD-compatible
parser and execution engine; TigerSqlCmd adds connection management, interaction policy,
output routing, logging, E2E lifecycle commands, and external-process integration.
On Windows, install it directly from the WinGet community repository:
winget install ItTiger.TigerSqlCmdOr install it as a global .NET tool with the .NET 10 SDK:
dotnet tool install --global ItTiger.TigerSqlCmdNormal invocations are semi-interactive. Add --non-interactive to the same commands
for CI, scheduled jobs, scripts, and agents: missing promptable values fail clearly
instead of blocking for input. Session-scoped E2E commands create disposable databases
with explicit ownership and safe cleanup, while non-owning clones can target existing
databases without making them droppable. The exec command resolves a saved connection
and hands it to an external tool through a supported environment-variable or argument
handoff. tiger-sqlcmd --completion <shell> prints tab completion for Bash, Zsh, Fish,
and PowerShell.
Start with the TigerSqlCmd general guide and the TigerSqlCmd E2E guide.
Read the published TigerQuery documentation.
- TigerSqlCmd interaction modes and usage
- TigerSqlCmd E2E scenarios
execexternal-tool handoff- SQL batch command timeouts
TigerQuery is not a clone of sqlcmd.
Itβs a deliberate reimplementation β compatible where it matters, safer where it should be, and documented with precision.
Unlike sqlcmd or SSMS, TigerQuery:
- Has a dedicated, composable parser
- Tracks batch structure and execution metadata
- Is fully test-covered and intentionally divergent where appropriate
- β
SQLCMD-compatible script execution β run inline SQL or files with
:setvar,$(var),:on error,GO [n], variables, repeatable batches, and sqlcmd-compatible stop-on-error behavior. - β
Controlled automation and result routing β use
SqlCmdExto protect host-provided values, and route results and messages to the console, CSV output, per-result-set files, or separate error output. - β Reusable connections without embedded secrets β save named SQL Server profiles and resolve server, database, username, password, or complete connection strings from supported external value references.
- β
One command model for people and automation β the same commands work in
guided semi-interactive mode and automation-safe
--non-interactivemode for scripts, CI jobs, scheduled work, redirected runs, and coding agents. - β Session-scoped E2E databases β create an isolated database and paired connection for one session, optionally provisioned for memory-optimized tables, then clean up by the exact session ID.
- β Ownership-safe E2E cleanup β only explicitly owned databases can be dropped; exact metadata, session, name, and authorization checks guard teardown.
- β Non-owning E2E clones β clone a saved profile to target a pre-existing database without taking ownership or granting cleanup permission to drop it.
- β
External-tool bridging β
tiger-sqlcmd exec --connection ... -- <tool> ...resolves a saved connection and passes it to a child process through supported environment-variable and argument handoff modes. - β
Explicit execution budgets β set a per-batch
--command-timeout, including0for no limit, for migrations, provisioning, and other long-running SQL. - β Composable .NET APIs β use the asynchronous parser and engine, structured callbacks and results, connection-profile components, or reusable TigerCli commands directly in applications.
SqlCmdEx is TigerQueryβs extended scripting mode for applications and
automation. It keeps familiar sqlcmd script syntax while allowing the host
application to provide protected variables that scripts cannot override with
:setvar.
| Mode | Application-provided variables | Script-local variables |
|---|---|---|
SqlCmd |
Seed the variable table, but :setvar can replace them |
Created and updated by :setvar |
SqlCmdEx |
Take precedence; matching :setvar assignments are ignored |
Still work when they do not conflict with protected host values |
Variable names are matched case-insensitively. For example, this script tries
to replace TargetDatabase:
:setvar TargetDatabase ScriptDatabase
PRINT 'Deploying $(TargetDatabase)';
GOThe host can protect its value by selecting SqlCmdEx:
using System;
using System.Collections.Generic;
using ItTiger.TigerQuery;
using ItTiger.TigerQuery.Engine;
const string script = """
:setvar TargetDatabase ScriptDatabase
PRINT 'Deploying $(TargetDatabase)';
GO
""";
var options = new TigerQueryEngineOptions
{
ConnectionString =
"Server=localhost;Database=master;Integrated Security=true;TrustServerCertificate=true",
Mode = SqlCmdMode.SqlCmdEx,
Variables = new Dictionary<string, string>
{
["TargetDatabase"] = "HostDatabase"
},
OnMessage = (message, _) => Console.WriteLine(message.Text)
};
await new TigerQueryEngine(options).RunFromStringAsync(script);
// PRINT reports: Deploying HostDatabaseThis is useful for deployment automation, test orchestration, code generation, database provisioning, and applications that inject environment or project values into reusable scripts without allowing accidental overrides.
See SqlCmd and SqlCmdEx in the hosted documentation for the detailed precedence rules.
SqlCmdEx works with both execution modes. Streaming is the memory-efficient
default; prepared execution parses the complete TigerQuery/sqlcmd structure
before opening the SQL connection. Mode selection and execution timing are
independent choices.
See prepared versus streaming execution for the trade-offs.
TigerQuery uses a structured unit test suite to document:
- π Known compatibility issues
- π‘ Intentional differences from
sqlcmdor SSMS - π§ͺ Parser edge cases, whitespace behavior, comment handling
- π§ Design decisions that prioritize clarity over legacy quirks
See:
Normal execution is semi-interactive and may prompt for eligible missing input. Add
--non-interactive to the same command for unattended use; menus, prompts,
confirmations, and keyboard input are disabled, while validation, execution, output,
diagnostics, and exit-code mapping remain active. See
One Command Model, Multiple Interaction Modes.
tiger-sqlcmd run -c local -m sqlcmdex -f script.sqlHere, local is a saved connection managed with tiger-sqlcmd connection.
The run command supports -v name=value for variables, --verbosity,
--log-level, and more. Route result sets to TigerQuery's built-in CSV writer
with -o/--output:
tiger-sqlcmd run -c local -f script.sql -o results.csvUse --output-mode FilePerResultSet for generated per-result-set files,
-e/--error-output for SQL errors, and --out-behavior to choose whether
:Out also redirects normal messages. See the
result output routing feature guide for the
complete CLI, API, CSV, overwrite, naming, encoding, and partial-file contract.
Saved connections live in a per-user JSON store shared across Tiger tools. A single run can point somewhere else β a scratch store, a CI workspace, a container mount β without touching that default:
tiger-sqlcmd connection list --tq-connection-store-file /tmp/scratch.json
export TIGERQUERY_CONNECTION_STORE_FILE=/workspace/runtime/connections.jsonThe command-line option wins over the environment variable, which wins over the
application default. A store path that is supplied but unusable fails the run
rather than quietly falling back, so a mistyped CI path can never send a job to
a developer's personal store. The option is app-wide in meaning but still an
option, so write it after the command path and any positionals; use
--tq-connection-store-file=<path> when the path begins with -. See
selecting the connection store.
After configuring the authorized tiger-sqlcmd-e2e bootstrap, create a database
and its paired owning connection with one session correlation ID:
tiger-sqlcmd e2e create --session-id 11111111-2222-3333-4444-555555555555 --name-part smoke --non-interactive
tiger-sqlcmd e2e cleanup --session-id 11111111-2222-3333-4444-555555555555 --non-interactiveTo target a pre-existing database without granting TigerQuery permission to drop it:
tiger-sqlcmd connection clone-e2e source --database ExistingDb \
--session-id 11111111-2222-3333-4444-555555555555 --name-part readonly \
--non-interactiveSee TigerSqlCmd E2E scenarios for the complete bootstrap, session, CI/agent, clone, cleanup, and recovery workflows. The E2E connection-store architecture remains the underlying safety contract.
| Package | Purpose |
|---|---|
ItTiger.TigerQuery |
Standalone sqlcmd-compatible SQL script parser and execution engine |
ItTiger.TigerQuery.Core |
Saved SQL Server connection profiles: storage, validation, resolution, same-store copying |
ItTiger.TigerQuery.CliCore |
Reusable TigerCli connection-management commands for CLI apps |
dotnet add package ItTiger.TigerQuerydotnet add package ItTiger.TigerQuery.Coredotnet add package ItTiger.TigerQuery.CliCoreOn Windows, the simplest machine-wide installation is WinGet:
winget install ItTiger.TigerSqlCmdWinGet resolves the Microsoft.DotNet.Runtime.10 package dependency and installs
TigerSqlCmd from the published versioned installer. winget upgrade ItTiger.TigerSqlCmd
moves a 0.8.8 or earlier installation to the current installer and keeps your saved
connections.
Alternatively, install the tiger-sqlcmd .NET tool globally:
dotnet tool install --global ItTiger.TigerSqlCmdThe tool targets .NET 10, so run installation with a .NET 10 SDK. An older SDK
can misleadingly report that DotnetToolSettings.xml is missing even though it
is present in the package; check dotnet --version and any applicable
global.json if that message appears.
For a repository-local installation, create or reuse a tool manifest and install the same package locally:
dotnet new tool-manifest
dotnet tool install --local ItTiger.TigerSqlCmd
dotnet tool run tiger-sqlcmd --helpUpdate or remove the global tool with:
dotnet tool update --global ItTiger.TigerSqlCmd
dotnet tool uninstall --global ItTiger.TigerSqlCmdFor a local manifest, replace --global with --local. The standalone machine-wide
Windows installer, TigerSqlCmd-<version>-Setup.exe, is also distributed through
GitHub releases. It requires
administrator elevation, installs under %ProgramFiles%\TigerSqlCmd, adds TigerSqlCmd to
the system PATH, and installs the .NET 10 runtime when it is missing. See
TigerSqlCmd concepts and usage for all installation
options and the command reference.
Uninstalling β through WinGet, Apps & Features, or dotnet tool uninstall β removes the
program and, for the installer, its PATH entry. It leaves your data in place: the shared
connection store (%APPDATA%\ItTiger.net\sqlserver-connections.json on Windows,
~/.config/ItTiger.net/sqlserver-connections.json elsewhere), which other Tiger tools may
also use, and any SQL scripts, result files, and log files you created. It also leaves the
.NET runtime, which other applications may use. Upgrades and reinstalls keep saved
connections and their protected passwords. Delete the store file yourself when you no
longer want those connections; no uninstaller touches SQL Server databases.
What TigerSqlCmd stores, sends, and removes is described in its privacy statement,
PRIVACY.md; each release attaches the statement that applies to it. The
third-party components the installer and the .NET tool include are listed, with their
licences, in THIRD-PARTY-NOTICES.md.
TigerQuery is an open-source project by IT Tiger, licensed under the MIT License
(LICENSE). Copyright (c) 2025 Ryszard Kozlowski.
π Project page: https://www.ittiger.net/projects/tigerquery/
π https://www.ittiger.net/

