-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlnotebook-cmd.html
More file actions
92 lines (87 loc) · 3.96 KB
/
sqlnotebook-cmd.html
File metadata and controls
92 lines (87 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>SqlNotebookCmd Command Line Tool - SQL Notebook</title>
<link rel="stylesheet" href="sqlnotebook.css">
</head>
<body>
<header>
<table class="nav">
<tr>
<td>
<a href="index.html"><img src="art/SqlNotebookIcon.png" alt="SQL Notebook (logo)" style="width: 58px; height: 58px; float: left; margin-right: 20px;"></a>
</td>
<td>
<a href="index.html" id="title">SQL Notebook</a><br>
<nav>
<ul class="nav">
<li><a href="https://github.com/brianluft/sqlnotebook/releases">Download</a></li>
<li><a href="doc.html"><span id="header-doc-long">Documentation</span><span id="header-doc-short">Docs</span></a></li>
<li><a href="https://github.com/brianluft/sqlnotebook">GitHub</a></li>
</ul>
</nav>
</td>
</tr>
</table>
<hr style="margin-top: 15px; margin-bottom: 15px;">
</header>
<article><div id="article">
<h1><code>SqlNotebookCmd</code> Command Line Tool</h1>
<p>The <code>SqlNotebookCmd</code> 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.</p>
<p>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.</p>
<h2>Syntax</h2><code>SqlNotebookCmd <<i>notebook-file</i>> <<i>script-name</i>></code><br>
<code>SqlNotebookCmd --help</code><br>
<h2>Parameters</h2>
<ul class="args">
<li><i>notebook-file</i>: text<br>
The path to the SQL Notebook file (.sqlnb) containing the script to execute. The file must exist and be a valid SQL
Notebook file.</li>
<li><i>script-name</i>: text<br>
The name of the script within the notebook to execute. Script names are case-insensitive. If the script name
contains spaces or special characters, enclose it in quotes.</li>
<li><code>--help</code>, <code>-h</code>, <code>/?</code>: option<br>
Display usage information and exit.</li>
</ul>
<h2>Output Format</h2>
<p>The tool outputs results in the following order:</p>
<ol>
<li>Any scalar result from the script (if present)</li>
<li>Any text output from <code>PRINT</code> statements</li>
<li>Data tables in CSV format with headers</li>
</ol>
<p>Multiple data tables are separated by blank lines. There is no blank line after the final table.</p>
<h2>Exit Codes</h2>
<ul>
<li><code>0</code>: Success - the script executed without errors</li>
<li><code>1</code>: Error - invalid arguments, file not found, script not found, or execution error</li>
</ul>
<h2>Examples</h2>
<pre><i>-- Execute script "MyScript" in the specified notebook</i>
SqlNotebookCmd "C:\data\mynotebook.sqlnb" "MyScript"
<i>-- Execute script with spaces in the name</i>
SqlNotebookCmd "C:\data\reports.sqlnb" "Monthly Report"
<i>-- Show help information</i>
SqlNotebookCmd --help
<i>-- Example with output redirection</i>
SqlNotebookCmd "data.sqlnb" "ExportData" > output.csv</pre>
<h2>Notes</h2>
<ul>
<li>By default, any changes made by the script are discarded and not saved to the file. To persist changes, use the
<code>SAVE</code> statement within your script.</li>
<li>The script must exist in the notebook's script collection. Page scripts are not accessible through this
tool.</li>
<li>Parameters and variables declared in the script work normally, but cannot be passed from the command line.</li>
<li>All output is written to standard output, making it suitable for piping to other command-line tools.</li>
</ul>
</div></article>
<footer><div id="footer">
<hr>
© 2016-2025 <a href="https://github.com/electroly">Brian Luft</a>
</div></footer>
</body>
</html>