My task was to load a provider table. A provider can be appointed to multiple hospitals. However, my source file was flattened and only listed a provider one time and had extra columns to determine each hospital they were appointed to. Below is a simple illustration of what the source file's data looked like:
- Provider A, Hospital 1, Hospital 2, Hospital 3
- Provider B, Hospital 1, Hospital 2, Null
- Provider C, Null, Hospital 2, Null
I decided to play around with the Conditional Split data flow transformation task. My first pass was to create a condition for providers that met the conditions to belong to each hospital. I created 3 conditions - Hospital 1, Hospital 2, Hospital 3.
Because the provider can belong to all 3 hospitals at once, doing it in a single pass wasn't going to work (as I quickly found out). The Conditional Split evaluates the record only once as soon as it meets the first criteria. This makes too much sense because that's how your basic If...Then...Else logic works. If it meets the first condition, it never gets to the next condition. Duh (blond moment) - it's not a loop.
So I then created 3 separate data flow tasks for each hospital w/ their own Conditional Split. Another option would have been to create a stored procedure with a couple of cursors. But I wanted to play with the functionality within SSIS. I think I can streamline this even more if I were to do some looping using the control flow items 'For' or 'Foreach' Loop Containers. I'll look into those next...
Back to Conditional Splits - it took me some getting use to when evaluating Nulls. For example, my Hospital 1 condition was met if Hospital 1 start date is not null and Hospital 1 end date is null. The condition expression ended up looking like this:
- !ISNULL([Hospital 1 Start Date]) && ISNULL([Hospital 1 End Date])