Skip to main content

Query Tag Tutorial


Explains how to use the query tag.


Designed primarily to be used with large SQL databases, query tags let you save the results of a query and then later refer to the data retrieved by that query without having to re-access the database. This saves resources, because you aren't making unnecessary calls to the database (which can eat up system resources.)

Use the query tag to retrieve the value of a specified data item (group) from your data source, storing the result in a newly created variable. The name of this variable can subsequently be used in other tags as a relative data reference, using ${name}.


Step 1

Selecting the Query Tag, this can be done through the Tag Builder. For this example we will be using the Northwind - Data.xml​ datasource.  


Note: When AutoTag is installed, several sample datasources are provided.  The default location for the sample datasources is C:\Users\<username>\Documents\AutoTag\data​ on the computer where AutoTag is installed.

Click here for additional information on connecting to datasources.


Tag Builder Query Tag.PNG


Once the Query Tag is selected click the Select tab in the Tag Editor. Drag the node from the data pane into the select box and evaluate to ensure the process was done correctly and you have the correct data.

Be sure to create a var name.  For this example we will use the var name ${employees}. 

Once evaluated, by default the viewer will show the first employee information or the first data set. To change which data set you want your query to look at click the wizard button to proceed to the Xpath Wizard.


Select node for query tag.PNG


For this example we will choose the employee with Employee ID equal to 5. Click ok and the window will close. XPath Wizard node filter.PNG


The Tag Editor viewer will now show the employee with Employee ID equal to 5’s information.

   Tag Editor Query Tag with Filter.PNG

Step 2

Create Out tags to display information from the Query Tag.

Now let’s say we want to have our report have the first name, last name and date of birth of the specific employee contained in our Query Tag.


Create some titles in your Word template as follows:


First Name:

Last Name:

Date of Birth:


Place Out tags next to your titles:


First Name: [out]

Last Name: [out]

Date of Birth: [out]


Steps to associate data with your Out tags:

  1. Select the Out tag next to First Name, and go to the Data Tree under the AutoTag tab. There is now a query family of nodes in the Data Tree.

Data Tree Query Tag.PNG


  1. Select First Name under the query family of nodes. This Out tag will now only output the first name of the Employee whose ID is equal to 5.
  2. Continue this process for Last Name and Birth Date. Make sure to make the Date of Birth tag a Date tag found under Type.


Data Tree Select first name from query.PNG

As a result your tags should resemble below,


First Name: [FirstName]

Last Name:[LastName]

Date of Birth:[BirthDate]


Save and run your report and the end result will resemble this, information only on employee with Employee ID equal to 5.


First Name: Steven

Last Name: Buchanan

Date of Birth: 3/4/1955 

  • Was this article helpful?