# Filtered Shema Export With In List

**URL:** <https://forums.toadworld.com/t/filtered-shema-export-with-in-list/48369>\
**Category:** Toad Data Point & Toad Intelligence Central\
**Created:** [December 5, 2019, 3:30pm UTC](https://forums.toadworld.com/t/filtered-shema-export-with-in-list/48369 "2019-12-05T15:30:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rossjustin](https://avatars.discourse-cdn.com/v4/letter/r/b9bd4f/32.png) [@rossjustin](https://forums.toadworld.com/u/rossjustin)\
**Post date:** [December 5, 2019, 3:30pm UTC](https://forums.toadworld.com/t/filtered-shema-export-with-in-list/48369/1 "2019-12-05T15:30:45Z")

</div>

What is the easiest way to do a mass export of 300 tables in a schema with an in list. The in list is set as a variable in the beginning of the automation script. There are 2 clients with the same table names in each.

**Example of export I need for 300 different tables:**  
SELECT \* FROM client1.table1 WHERE LOAN\_NUMBER IN (&VARIABLE)  
UNION ALL  
SELECT \* FROM client2.table1 WHERE LOAN\_NUMBER IN (&VARIABLE)

Is creating 300 different exports the only way this is possible?

The exports need to go to .txt files that are named the same as the table.  
**Example:**  
table1.txt

Thank you for any assistance/guidance. I do not look forward to doing this manually 300 times. The initial build will be a time consuming monotonous bore.

---

<div class="post-metadata">

**Author:** ![Gary.Jerep](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/gary.jerep/32/205_2.png) [@Gary.Jerep](https://forums.toadworld.com/u/Gary.Jerep)\
**Post date:** [December 5, 2019, 5:39pm UTC](https://forums.toadworld.com/t/filtered-shema-export-with-in-list/48369/2 "2019-12-05T17:39:32Z")

</div>

I don't have the bandwidth right now to test my idea, but with TDP's Automation Designer, it's possible to create an Automation job that

1. Reads in your table names, probably from a flat file or a table (the "in list", if I'm understanding you correctly) and assign the name to a variable
2. Loops through each of the names in the list, and for each one...  
a. Execute your query (using the current variable-ized table name)  
b. Export to CSV using the variable value for the export file name

When I get some time next week, I can try to set up an example and share if I'm successful (unless you beat me to it!)

---

<div class="post-metadata">

**Author:** ![rossjustin](https://avatars.discourse-cdn.com/v4/letter/r/b9bd4f/32.png) [@rossjustin](https://forums.toadworld.com/u/rossjustin)\
**Post date:** [December 6, 2019, 7:05pm UTC](https://forums.toadworld.com/t/filtered-shema-export-with-in-list/48369/3 "2019-12-06T19:05:05Z")

</div>

Figured it out using variables and looping. We loop through table names in the schema with a query which dynamically names the files on export and moves on to the next in the list of looping.

---

<div class="post-metadata">

**Author:** ![Gary.Jerep](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/gary.jerep/32/205_2.png) [@Gary.Jerep](https://forums.toadworld.com/u/Gary.Jerep)\
**Post date:** [December 6, 2019, 7:24pm UTC](https://forums.toadworld.com/t/filtered-shema-export-with-in-list/48369/4 "2019-12-06T19:24:57Z")

</div>

Glad the idea worked out. Would you mind sharing any details of the automation job? I know there are other users who would like to do the same thing.

---

<div class="post-metadata">

**Author:** ![rossjustin](https://avatars.discourse-cdn.com/v4/letter/r/b9bd4f/32.png) [@rossjustin](https://forums.toadworld.com/u/rossjustin)\
**Post date:** [December 6, 2019, 8:44pm UTC](https://forums.toadworld.com/t/filtered-shema-export-with-in-list/48369/5 "2019-12-06T20:44:42Z")

</div>

![image](https://global.discourse-cdn.com/quest/original/2X/0/0425073becc6f5d3dd4a782daa163a3378be0a55.png)
