SqlNotebookCmd Command Line Tool

The SqlNotebookCmd command line tool allows you to execute scripts inside SQL Notebook files (.sqlnb) from the command line without opening the GUI. This is useful for automation, batch processing, and integration with other command-line tools and scripts.

The tool executes the specified script and outputs any results to standard output in CSV format. On success, the exit code is 0. On error, the exit code is 1 and error messages are written to standard error.

Syntax

SqlNotebookCmd <notebook-file> <script-name>
SqlNotebookCmd --help

Parameters

Output Format

The tool outputs results in the following order:

  1. Any scalar result from the script (if present)
  2. Any text output from PRINT statements
  3. Data tables in CSV format with headers

Multiple data tables are separated by blank lines. There is no blank line after the final table.

Exit Codes

Examples

-- Execute script "MyScript" in the specified notebook
SqlNotebookCmd "C:\data\mynotebook.sqlnb" "MyScript"

-- Execute script with spaces in the name
SqlNotebookCmd "C:\data\reports.sqlnb" "Monthly Report"

-- Show help information
SqlNotebookCmd --help

-- Example with output redirection
SqlNotebookCmd "data.sqlnb" "ExportData" > output.csv

Notes