Using Filters
Previous Top Next

Filters are used to determine if an action in the task should execute or not. There are many scenarios when you may want to apply a filter to an action, one such a scenario would be if you want to split processing requirements for customers from different countries for example.

The Northwind database contains a customers table with many customers records in, one of the fields in the table is the country.

We extract all the customer records with a single SQL select statement and the SQL Task component:

graphic

For this example we’ll extract only the US and UK customers in separate files using filters.

We’ll use two Write to File components to write the Customer’s name and Country to a text file. The first text file will contain all US customers and the second the UK customers.

The first Write to File component is configured to write to a file called C:\US.TXT

graphic

We use a filter on the first Write to File component to specify that we only want records that contain the word “USA” in the Country field from the Dataset that was returned by the SQL Task:

graphic

Note the “customers.Country = USA” filter above.

The second Write to File component is configured to write to “C:\UK.TXT”

graphic

We will also a filter on the second Write to File component to specify that we only want records that contain the word “UK” in the Country field from the Dataset that was returned by the SQL Task:

graphic

When we run the task the following two files are produced:

graphic