Mail Merge Labels in Word Using Query Results

This document presents a sample query that, when run using the SOS-supplied DBISQL utility, produces an EXCEL file that can be used as the data to produce a set of mailing labels in MS Word. There is a document on the SOS web site that describes how to run queries:

Specifically, it selects from the main data set (licnum = 101), only certain primary providers, and only those with a non-zero service within the last 270 days. The results of the query are saved in a file called LABELS.HTML in the SOS folder on the C: drive (see last line of the query). You can copy and paste the query below directly into DBISQL, then make any changes you like before running it.
TRIM(a.firstname) AS “First Name”,
TRIM(a.lastname) AS “Last Name”,
a.addr1 AS “Address 1”,
a.addr2 AS “Address 2”,
TRIM(city) AS “City”,
TRIM(state) AS “State”,
rv_patients a
JOIN ptvars b ON a.ptnum = b.ptnum
a.licnum = 101
AND a.priprvcode IN (‘AB’,’CD’,’EF’,’GH’)
AND b.lfeedate > (TODAY() – 270)
a.lastname, a.firstname
OUTPUT TO c:\sos\labels.html FORMAT HTML

Once you have run your query successfully, open the resulting XLS file in MS EXCEL and re-save it. That will put it into the file format that your particular version of MS Word likes best. Now open your web browser and go to:

to view a short Flash video that demonstrates how to create your labels using the output of your query. Depending on the speed of your internet connection, the video may take a while to load. (If you don’t have the Flash add-in installed, your browser will probably offer to download and install it for

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.