[[Invantive Script/Invantive Script|Invantive Script]] is the client-side language which surrounds a statement: it writes a file, reads one, sets a variable, sends a mail, and decides what runs. Its statements are written in the same document as the SQL and are executed with "Execute" or "Execute All" like any other. ## What It Adds SQL says what data is wanted. Script says what happens with it and where it comes from or goes to: ```sql local export results as csv to "c:\temp\projects.csv" select * from Projects@dummy ``` The export writes the answer of the statement which follows it, without the grid and without a hand on the mouse. That is the same route the [[Invantive Query Tool/Exporting Results|export menu]] takes, in a form which can be repeated. ## Why It Is Worth Writing in the Query Tool A script written here runs unchanged in [[Invantive Data Hub/Invantive Data Hub|Invantive Data Hub]], which is the same engine without a user interface. Trying a script in the editor - with the grid, the [[Invantive Query Tool/Progress|Progress]] panel and the [[Invantive Query Tool/Trace|Trace]] panel to look at - and then scheduling the file as it stands is the shortest route from a question to something which runs every night. ## What to Watch - A `local` statement needs a blank line before it, since a blank line is what separates one statement from the next in a script. - Variables set by a script live for the run; the pre-defined ones are listed under [[Invantive Script/Pre-defined Variables|Pre-defined Variables]]. - A path is a path on the machine the product runs on, and a scheduled run on a server therefore writes on that server rather than on the workstation. The language itself - its statements, its variables and its file handling - is documented under [[Invantive Script/Invantive Script|Invantive Script]].