SQL - Part 1: Basic Selection


To learn about the SQL Wizard, and replicate the process of creating a ForEach table with a simple selection of 4 columns of data through the creation of an employee photo directory.

Background Information

Up until this point, you most likely have been selecting only one table at a time for your ForEach tags and had no way of sorting or filtering your data. The SQL Wizard is a very powerful tool that can aid you in your quest for the ultimate data (and to please your boss with a good report)! Here you will learn the basics of the SQL Wizard, and your knowledge can only expand after this.


Inserting a Tag, ForEach Tag, Out Tag - Displaying Images


1. Insert MSSQL datasource

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.

Show Me How!

2. Insert a table with 3 named columns

Open the Insert menu in Word, and click the Table button to insert a table. Select a 3X2 table. In the interest of spicing this design up in the simplest way possible, we’re going to select a table style from the menu that pops up (if you lose it, it’s one of the highlighted Table Tools ribbons, called Design) The styles are right in the center of the ribbon. We chose the third one called Plain Table 1

Now, we’re going to go ahead and name the columns. Employee, Phone, and Photo are the names we use since we’re going to try to make a photo directory for the companies employees.

Show Me How!

3. Insert ForEach and Out tags

Now we’ll insert a ForEach tag, just as before. Open the AutoTag ribbon, find the Tags button and select the ForEach tag. We’ll give it a nickname, [forEach Employee: and a variable name:employee Also insert 4 out tags (two under the “Employee” column for a first and last name) and an End ForEach tag using the same device.

Show Me How!

4. Open the SQL Wizard

To do this, select the ForEach tag you just created, and under the AutoTag ribbon, click the Wizard button. This pops up a window called the SQL Wizard. Feel free to take a look around. We’ll explain what everything does in step 7.

Show Me How!

5. Drag the columns you need

In the middle pane, there is a box labeled Columns. We need to drag any data we want to work with to this box. This data will later be accessible by the out tags inside the ForEach tag we are working on. We’re going to go ahead and drag in the HomePhone, PostalCode and Photo.

Show Me How!

6. Remove a column and insert more

We actually don’t need PostalCode, but we added it so we can demonstrate how to remove columns you don’t need. To do this, simply click the desired column with your left mouse button and select remove. Finally for this step, insert the FirstName and LastName columns at the top.

Show Me How!

7. Inspect the window (then close it)

There are three main components you should take a look at here. The left pane holds all of your data, and the right pane holds the returned results (which includes any sorting or filtering you may apply). The middle pane has boxes labeled Columns, Sort, Filter and Join Tables.

If you take a look at the tutorial listing, we have tutorials to exclusively cover operations in each of these boxes, but the run down is as follows: Columns is where you drag data you want to work with, Sort is where you drag data you want to sort by, Filter is where you create conditions to filter your data and Join Tables is really an informational box that shows how tables have been automatically joined.

Show Me How!

8. Select data for out tags

All we have left to do is set the out tags to display the data we just found in the SQL Wizard. Hopefully you have lots of practice in this already since you’ve done it in nearly every tutorial so far. Click the tag, open the Data tree and select a piece of data. With the SQL Wizard, we have only returned 4 columns which means the Data tree is a lot simpler to look at now!

Show Me How!

9. Generate and view results

You should be well versed in this step as well. If you have any problems here, please take a look at some of the tutorials under AutoTag Basics

Show Me How!

Quiz Yourself!

What is the SQL Wizard for?
Creating my template for me without me doing any work
Creating entries in my SQL database
Retrieving data from a SQL database by using sorting, filtering and joining
Setting up a SQL datasource to use in an AutoTag template
How do you select data in the SQL Wizard?
Type in a complex select statement into the select box
Drag and drop columns in an easy-to-use interface that generates a select statement for me
Open the Data tree just like when I’m selecting data without the SQL Wizard
What does the SQL Wizard do that you couldn’t do before?
It grants me three wishes
It is the only way to select data for the tags in my template
It provides an easy-to-use interface where I can choose what data to return, and sort and filter it, and it’s very quick too
It fills in my template with data for me, without any action on my part.


You have completed this tutorial. We recommend taking a look at the SQL - Part 2: Sorting tutorial next!