Export & Dump
BroadSQL writes query results to a local file in one of two ways:
EXPORT <fileName>(synonymsEXP,EXTRACT,EXT): a toggle. Once turned on, every SQL statement you run afterwards writes its result to that file instead of the screen, untilEXPORTis called again with no argument (turns it off) or with a new file name. See command reference.DUMP <tableName>: a one-shot export of an entire table's content, in a single step. See command reference.
Both share the same destination-folder rule, the same extension-to-format mapping, and the same DefaultFileFormat setting described below.
Recommended alternative for new scripts: PULL covers the same ground (PULL <source> TO <name> AS CSV/TXT, or AS XLSX/ODS for a multi-tab spreadsheet) with one unified syntax and an explicit destination name/format, instead of EXPORT's toggle or DUMP's automatic format choice. EXPORT/DUMP aren't going anywhere and keep working exactly as described on this page; PULL's CSV output just uses a separate CsvSeparator setting rather than FieldsSeparator/ SET SEPARATOR, and rejects a column it can't map instead of writing whatever the driver returns for it (see PULL for the full comparison).
Where files are written
EXPORT: iffileNameincludes a directory, that directory must already exist or the command fails with an error. If it doesn't include one, the file is written toDefaultFolder(see Application settings).DUMP: always writes toDefaultFolder, named after the table exactly as typed (schema included, e.g.DUMP PUBLIC.CUSTOMERproducesPUBLIC.CUSTOMER.<ext>). There is no option to choose the destination or file name. UnlikeEXPORT,DUMPdoes not check thatDefaultFolderexists first.
Choosing a format
The format is determined by the file's extension:
| Extension | Format | Written by |
|---|---|---|
.xlsx | Excel 2007+ | Apache POI |
.ods | OpenDocument Spreadsheet | SODS |
.csv | Comma-separated text | Built-in text writer |
.txt (or any other/no recognized extension) | Delimited text | Built-in text writer |
.mdb | MS Access (2000 format), legacy, frozen (see below) | Jackcess |
.xls | (not supported) | Fails with an explicit error suggesting .xlsx |
If EXPORT is given a file name with no extension, one is appended automatically based on DefaultFileFormat (see below): .xlsx, .ods, .csv, or .txt. DUMP never receives an extension from the user; it always picks one itself:
- At or below the
MaxRowXLSXthreshold (or when the row count can't be determined), it uses the extension matchingDefaultFileFormat. - Above
MaxRowXLSX, it always writes a tab-separated.txtfile, regardless ofDefaultFileFormator the configuredFieldsSeparator.
DefaultFileFormat
INI setting ([General], see Application settings) controlling the default format above. Accepted values: XLSX, ODS, CSV, TXT (not case-sensitive). It is the only optional export-related setting:
- Missing from the file: BroadSQL prints an
INFOmessage at startup and uses ODS. - Present but not one of the four values: the value is ignored, BroadSQL prints an
INFOmessage at startup explaining why, and uses ODS. - Valid: used as given, no message.
This setting only supplies a default. Naming an extension explicitly always wins: `EXPORT totals.csv always produces a CSV file no matter what DefaultFileFormat` says.
CSV vs. TXT
Before this setting existed, .csv and .txt produced an identical file; only the extension differed. They are now distinct:
.csvalways uses a comma, regardless ofFieldsSeparatororSET SEPARATOR..txt(and any other/unrecognized extension) uses the configured separator (FieldsSeparatorin the INI, or whateverSET SEPARATORlast set for the session, tab by default).
Both otherwise share the same writer and behavior (see "CSV / TXT" below).
Interrupting an export
Pressing CTRL+C during an .xlsx, .ods, .csv, or .txt export stops the write cleanly without closing the database connection: rows written so far stay in the file, the rest of the result set is discarded. (Not supported for .mdb.)
Per-format details
XLSX (Excel)
- A
NULLvalue produces a blank cell (not0/false/a placeholder date). DATE/TIME/TIMESTAMPcolumns get a real, typed Excel cell with a matching format (yyyy-MM-dd,hh:mm:ss,yyyy-MM-dd hh:mm:ss): the time-of-day on aTIMESTAMPis preserved, not truncated to midnight.BIGINT/DECIMAL/NUMERICvalues are written as a real (sortable, calculable) number when that round-trips exactly through a double; otherwise the cell falls back to exact text, since Excel numbers cannot represent arbitrary precision.- The sheet name is derived from the table/query and sanitized (Excel-forbidden characters removed, truncated to 31 characters). A second sheet named "Query" records the exact SQL text and when it ran.
- A sheet is capped at 1,048,576 data rows (Excel's own limit); beyond that, the export stops cleanly, the file remains valid, and a warning reports how many rows were and weren't exported.
- Binary columns (
BINARY/VARBINARY/LONGVARBINARY/OTHER/DATALINK) are written as the text "Binary content, not exported to Excel"; known limitation: this placeholder is currently shown even when the binary value is actuallyNULL, instead of a blank cell. BLOB/CLOB/NCLOBare not handled explicitly; they fall into the generic text case..xls(the legacy 97-2003 binary format) is not supported.
ODS (OpenDocument Spreadsheet)
- Same
NULL-handling, typedDATE/TIMESTAMPcells, and 1,048,576-row safety cap as XLSX above (the cap here is a memory safeguard, not an ODF format limit; unlike XLSX's streaming writer, the whole sheet is held in memory before being saved). TIMEcolumns have no dedicated cell type in the underlying library and are written as formatted text (HH:mm:ss).BIGINT/DECIMAL/NUMERICvalues are written with their exact decimal value, with no precision loss to guard against (unlike XLSX, the format doesn't round-trip through a double).- The header row is bold with a light blue background. There is no equivalent of Excel's "Query" recap sheet.
- Binary columns get the same "Binary content, not exported to ODS" placeholder as XLSX, but a
NULLbinary value correctly produces a blank cell. BLOB/CLOB/NCLOBare not handled explicitly; they fall into the generic text case.
CSV / TXT
- RFC 4180 quoting: a value containing the separator, a double quote, or a line break is wrapped in double quotes (internal quotes doubled).
- A true SQL
NULLproduces an empty field; the literal text"null"(or any other value) is written as-is; the two are never confused. - Always written as UTF-8 with a leading BOM, independent of the console's own encoding, so tools like Excel recognize accented characters correctly when opening the file directly.
- Re-running
EXPORTin append mode to an existing, non-empty file does not repeat the header row.
MDB (MS Access), legacy format, frozen
This format is frozen (28/08/2026): still fully supported, but not receiving further development. It is not part of PULL's unified formats (AS H2/AS XLSX/AS ODS/AS CSV/AS TXT/AS JSON/ AS MD/AS HTML; see PULL) and there is no plan to add it there. If your workflow depends on .mdb export and you'd like to see it continue evolving, let us know: real usage is exactly what would justify further investment.
- Written in the Access 2000 (
.mdb) file format via Jackcess, not.accdb(the format Access itself has defaulted to since Access 2007). - The table name is derived from the query/table the same way as the Excel sheet name (unsanitized).
- If the target
.mdbfile already exists, a new table is added into it; existing tables are left untouched. If it doesn't exist, a new database file is created.
Related pages
- Application settings:
DefaultFolder,DefaultFileFormat,MaxRowXLSX,FieldsSeparator. EXPORT,DUMP,SET SEPARATORcommand reference.
BroadSQL