-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport-txt-stmt.html
More file actions
73 lines (71 loc) · 3.24 KB
/
export-txt-stmt.html
File metadata and controls
73 lines (71 loc) · 3.24 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
<!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>EXPORT TXT Statement - 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><tt>EXPORT</tt> <tt>TXT</tt> Statement</h1>
<p>Writes a text file (.TXT) to disk from a <code>SELECT</code> query. If the query has multiple columns, they are
concatenated together with no separator. The text is not escaped or quoted.</p>
<h2>Syntax</h2><img src="art/export-txt-stmt-syntax.svg" alt="" class="railroad" moz-do-not-send="true" width="603"
height="261"><br>
<h2>Parameters</h2>
<ul class="args">
<li><i>filename</i>: text<br>
The absolute path to the text file to write. The file does not need to exist. If it does exist, by default new
lines will be appended to it. Use the <code>TRUNCATE_EXISTING_FILE</code> option to overwrite the existing
file.</li>
<li><i>select-statement</i>: statement<br>
A <code>SELECT</code> statement that provides the rows to write to the file.</li>
</ul>
<h2>Options</h2>
<ul class="opts">
<li>
<code>TRUNCATE_EXISTING_FILE</code>: integer (0-1, default: 0)<br>
If the output file exists, this option indicates whether the existing file contents should be deleted.
<ul class="enum">
<li>0 = Keep existing file data and append new lines</li>
<li>1 = Delete existing file data</li>
</ul>
</li>
<li>
<code>FILE_ENCODING</code>: integer (0-65535, default: 0)<br>
Indicates the text encoding to use when writing the text file. Specify 0 to use UTF-8. Any nonzero integer is
treated as a Windows code page number. See <a moz-do-not-send="true" href=
"character-encodings-in-csv-and-text-files.html">Character Encodings in CSV and Text Files</a> for a list of
these code page numbers.<br>
</li>
</ul>
<h2>Example</h2>
<pre><i>-- Writes the contents of mytable into a file called "MyFile.txt".</i><i><br></i><i>-- Because no options are specified, the lines are appended and</i><i><br></i><i>-- the UTF-8 encoding is used.</i><br>EXPORT TXT 'C:\MyFile.txt'<br>FROM (SELECT * FROM mytable);<br><br><i>-- Overwrites "MyFile.txt" if it already exists.</i><br>EXPORT TXT 'C:\MyFile.txt'<br>FROM (SELECT * FROM mytable)<br>OPTIONS (TRUNCATE_EXISTING_FILE: 1);<br></pre>
</div></article>
<footer><div id="footer">
<hr>
© 2016-2025 <a href="https://github.com/electroly">Brian Luft</a>
</div></footer>
</body>
</html>