Exporting Script results
Exporting a Script's result: DUMP LIB and DUMP @
DUMP LIB runs a library Script and writes its tabular result to a file. DUMP @ is the same command written the way a Script is run at the prompt. Named arguments come right after the Script, before TO and AS:
DUMP LIB customer-report.sql country='FR' TO customers_fr AS XLSX;
DUMP @customer-report.sql country='FR' TO customers_fr AS CSV;
- The Script runs through the normal Script engine, with its arguments, variables,
ON ERRORandOUTPUT. Its result tables are captured for the file instead of being displayed;ECHOmessages still appear. - The exported data is the Script's own final tabular result. A scalar
LET ... = SELECTquery is never the export result, and a result shown earlier at the prompt is never used: a Script that produces no tabular result exports nothing (produced no exportable tabular result; nothing was exported). - The file is written only when the Script's status is
SUCCESS. For any other status, nothing is written and an error says why:DUMP LIB errs.bsql not exported: the script finished with status COMPLETED_WITH_ERRORS. - With
AS XLSXorAS ODS,TOnames the file and, after a dot, the worksheet:TO customers_frwritescustomers_fr.xlsx, worksheetDATA. Do not add the extension yourself.
File names, formats and every other option are described in Export.
Related pages
- Scripting overview
- Export: every
DUMPsource, format and option. - Nested Scripts and run lifecycle: the statuses that decide whether a file is written.
- Examples: a complete report exported to a spreadsheet.
- Command reference:
DUMP,PULL.
BroadSQL