Previous Topic

Next Topic

Book Contents

Book Index

Technical Notes on Batch Jobs

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

*.bat File

An example of a *.bat file is as follows:

set aqtcmd=%cmdcmdline%

rem desc=This job is run nightly to update employee salaries

"C:\Program Files (x86)\Advanced Query Tool v11\aqtv11.exe" sqlfile="UpdateSalary.sql"


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)

Log File

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.

Running AQT in batch - Old Format

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.

Unqualified file names

If sqlfile and logfile filenames are unqualified, they will be qualified by Windows using the current working directory for the process.

Running AQT in batch - New Format

With AQT v11 there is a new format for running batch jobs.

aqtv11 sqlfile=<sqlfile>,logfile=<logfile>,jobdir=<jobdir>,append=y,desc=<description>



aqtv11.exe sqlfile="SalesReport.sql",desc="Weekly sales report for $weekdate"

Unqualified file names

If sqlfile is an unqualified filename, AQT will look in the following locations:

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.

*.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.

Sample Batch Jobs

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.

Advanced Query Tool
© 2023 Cardett Associates Ltd. All rights reserved.