An AQT batch job consists of two files:
These files can be in any location on your PC. However to be seen by the Manage Batch Jobs dialog they should be placed in the Batch Job directory. This is specified in Options > File Locations > Location of Batch Jobs. By default this is C:\Users\<username>\AppData\Roaming\Advanced Query Tool\batch
An example of a *.bat file is as follows:
Each of these statements is discussed below:
You can amend your bat file as you wish. For instance, you can set environment variables for AQT to read (which it can do with --aqt setparm)
When AQT is run in batch, it writes information to a log file about the running of the job. This is useful for determining whether the job ran successfully, and diagnosing any problems.
The command for running AQT in batch takes 2 formats. The format described here is used by AQT v10 and prior versions. For backward compatibility this is still an acceptable format with AQT v11.
aqtv11.exe sqlfile logfile
aqtv11.exe UpdateSalary.sql UpdateSalary.log
For clarity these filenames are shown as unqualified.
If sqlfile and logfile filenames are unqualified, they will be qualified by Windows using the current working directory for the process.
With AQT v11 there is a new format for running batch jobs.
If not specified, it will be file $jobname_$datetime,log in the logs sub-directory. This will ensure that a different log file is created every time the job is run.
If you wish to use the same log file for all runs of the job, you should use the append option:
aqtv11.exe sqlfile="SalesReport.sql",desc="Weekly sales report for $weekdate"
If sqlfile is an unqualified filename, AQT will look in the following locations:
Because there can be some uncertainly as to what sqlfile is read and where the logs are written, it is recommended that either fully-qualified filenames are used, or the set aqtcmd command be included.
If logfile is an unqualified filename, the log file will be written to the logs subdirectory of the sqlfile directory.
When the job is run, it is given a job name. The jobname will be shown in the Job History. It also forms part of the name of the log file.
This comes from the name of the bat file. If set aqtcmd is not given, AQT will not know the name of the bat file. In this case the job name will come from the name of the sql file.
The SQL file consists of a series of AQT scripting commands and SQL statements which AQT is to run.
A reference to the AQT scripting statements is given at Scripting Statements.
If you are running a Select statement you also need an --export command to specify how the data is to be exported.
For instance, in the Export Data window you can click on File > View Export Command. This will show you the command to export the data in the format specified by the options on the dialog. This command can be included in your SQL file.
AQT supplied a number of sample batch jobs. These are in the following directory:
C:\Users\<username>\AppData\Roaming\Advanced Query Tool\batch
They will be seen when you start the Manage Batch Jobs dialog.