To save the results of a query for use in an Autotag template, in order to prevent unnecessary duplicate database queries.
In the case of large databases, queries often eat system resources on both the database server, and the client who then has to handle the query results. The purpose of the query tag is to reduce this problem by eliminating duplicate queries.
Load the MSSQL datasource by clicking the bottom half of the "Data Sources" button, and selecting MSSQL. If there is no MSSQL option in the drop down menu, you may select another datasource, or follow the instructions in the "Creating a SQL datasource" tutorial.
Insert a Query Tag. It will not appear on the final report, however its location does affect what tags are able to access the data queried. It should appear before any tags that need to use that data.
We are going to query the entire Employees table--this way we can access any of the data in the Employees table and the database will only be queried once. Select the Employees table as you would normally select data for other tags.
Also, name the tag "[Query Employees]" and then set it's variable to "employees." In tags following the Query tag, the data queried is access by looking under the variable "employees."
Insert an out tag and then look in the Data tree. At the top is the "employees" variable which contains the data queried earlier. Under that variable, find and select First Name.
Evaluate the tag to see the results. This is to verify that the query retrieve the data correctly.
You have completed this tutorial. We recommend taking a look at the Inserting Pre-Made Tags from the Data Bin tutorial next!