I have a dts package that processes 3 data files, each of the three files need to be loaded into 3 corresponding tables. The three tables have relaionships where one table is the parent and the other two are children.
So here's my problem: If the parent file exits and both child files exist I will need to truncate both children first, then truncate the parent, then load the parent, then load both child tables. But all three files are rarely sent on the same day so I have to plan for any eventuality.
Here are the possible combinations WHERE 0 = File doesn't exist and 1 = File does exist.
P C1 C2
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
What I am trying to figure out is a workflow for the SQL Tasks that truncate and load the tables, without creating duplicate tasks for the package.
Example:
DTSTask_TrunctateChild1 & DTSTask_truncateChild2>>on successOfBoth>>DTSTask_TruncateParent>>on success>>DTSTask_LoadParent>>on success>>DTSTask_LoadChild1 & DTSTask_LoadChild2. This would take care of the last condition where all 3 files exist. I can create 7 more just like it but it seems to me there should be another way. I've looked into using the execute method of the Task/Step objects at run time but I my understanding is this is probably a bad idea.
Any suggestions are welcome.
So here's my problem: If the parent file exits and both child files exist I will need to truncate both children first, then truncate the parent, then load the parent, then load both child tables. But all three files are rarely sent on the same day so I have to plan for any eventuality.
Here are the possible combinations WHERE 0 = File doesn't exist and 1 = File does exist.
P C1 C2
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
What I am trying to figure out is a workflow for the SQL Tasks that truncate and load the tables, without creating duplicate tasks for the package.
Example:
DTSTask_TrunctateChild1 & DTSTask_truncateChild2>>on successOfBoth>>DTSTask_TruncateParent>>on success>>DTSTask_LoadParent>>on success>>DTSTask_LoadChild1 & DTSTask_LoadChild2. This would take care of the last condition where all 3 files exist. I can create 7 more just like it but it seems to me there should be another way. I've looked into using the execute method of the Task/Step objects at run time but I my understanding is this is probably a bad idea.
Any suggestions are welcome.