multiple data flow task
Hi all I am new at SSIS and I have a scenario which i have to achieve in the following way : I want to take one script task and multiple data flow task and as per certain condition i want to run any of the data flow task. i have so many XML files in a folder and in script task i am iterating all the xml files one by one on the base of specific node i want to cal a data flow task and i also want to pass the path name to xml source in that data flow task from my script only Kindly help me with the solution if any of you have. Thanks, Diwakar
July 16th, 2012 7:20am

You can use "precedence constraints" to have a conditional invocation of data flow tasks. Please refer http://www.buildingmeaning.com/?p=51 for more information on precedence constraints.~V
Free Windows Admin Tool Kit Click here and download it now
July 16th, 2012 7:32am

you can create an int variable in package, and check the condition as you like in script task and fill flag value in the int variable like If (<condition>) Dts.Variables["User::MyFlagVar"].Value=0; else if (<other condition>) Dts.Variables["User::MyFlagVar"].Value=1; else if .... ... then use precedence constraint to implement an IF Condition and switch between next tasks (which can be data flow tasks) this is a sample of implemeting IF condition with Precedence Constraint: http://www.rad.pasfu.com/index.php?/archives/11-Implement-If-condition-in-SSIS-package.html You can also create another variable for XMLFilePath and set its value in script and then use expressions to set Data Access Mode in XML Source in data flow task as XML File from Variable and set source variable there.http://www.rad.pasfu.com
July 16th, 2012 7:32am

Hi friend can you explain in detail how to run different different Data flow task i mean what would be the code for that
Free Windows Admin Tool Kit Click here and download it now
July 16th, 2012 8:14am

Hi Reza, I am using the following code in the script task public void Main() { string[] arrFiles = System.IO.Directory.GetFiles("C:\\multipleXmlFiles\\", "*.xml"); // Microsoft.SqlServer.Dts.Runtime.Application application = new Microsoft.SqlServer.Dts.Runtime.Application(); string firstNodeValue = string.Empty; string secondNodeValue = string.Empty; //string var1; foreach (string file in arrFiles) { XmlDocument doc = new XmlDocument(); doc.Load(file); if (doc.SelectSingleNode("//ProjectItem") != null) firstNodeValue = doc.SelectSingleNode("//ProjectItem").Name; if (doc.SelectSingleNode("//SqlTaskData") != null) secondNodeValue = doc.SelectSingleNode("//SqlTaskData").Name; if (!string.IsNullOrEmpty(firstNodeValue) && !string.IsNullOrEmpty(secondNodeValue)) { //var1 = "both"; var condVar = "1"; } else if (string.IsNullOrEmpty(firstNodeValue) && string.IsNullOrEmpty(secondNodeValue)) { //var1 = "simple"; var condVar = 2; } else if (!string.IsNullOrEmpty(firstNodeValue) && string.IsNullOrEmpty(secondNodeValue)) { //var1 = "cSharp"; var condVar = 3; } else if (string.IsNullOrEmpty(firstNodeValue) && !string.IsNullOrEmpty(secondNodeValue)) { //var1 = "sql"; var condVar = 4; } } // TODO: Add your code here Dts.TaskResult = (int)ScriptResults.Success; } } } And i have taken 4 data flow task after this script task but only script task is running non of the data flow task is running kindly help with your suggestion. Thanks, Diwakar
July 17th, 2012 3:01am

Hi Diwakar , it is as simple, 1. create four variables in package level . 2.In Script Task select all these variables as read write variables assign values as per requirement, say for eg: if(a>b) { Dts.Variables[User::var1].value=1; } 3. Form Script task drag connection(precedience constarint) to DataFlowTask (for all DFT's) 4. Edit each Precedence Constraint for eg for DFT 1 select expresion option , write expression as @var1==1 similarly do for other three. 5. Based on the expression DFT executes :) Thanks
Free Windows Admin Tool Kit Click here and download it now
July 17th, 2012 3:37am

Hi its not working still only script task is getting executed non of the data flow task is running after that
July 17th, 2012 4:48am

Please share the screenshot and expressions you have derived for prcedence constraint? Try debugging the code , by having message box in script and check for the variable values that has been assigned to that parameters.
Free Windows Admin Tool Kit Click here and download it now
July 17th, 2012 4:51am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics