Question

I have an SSIS package where I need to Execute a usp, check the row count coming back from the usp, then use the results from the usp if the row count is not 0 in a For Each loop. I would like to do this by only calling the DB once, but I can't figure out how. Right now I am using a Data Flow task with a OLE DB Source to EXECUTE the usp. I then have a row count task to get the count and assign it to a variable. In my control flow I then use this variable as an expression into the for each loop, which is working, but then I don't know how to actually loop through the query results as it is not currently assigned to anything. I was thinking to assign the OLE DB Source to a Variable but I am not sure how to do that, so I am open to other options as well.

Here is what I currently have:

Control Flow: enter image description here

Data Flow:

enter image description here

Was it helpful?

Solution

there probably are better solutions but not knowing your application and following your attempted solution what I can suggest you is the use of recordset destination:

enter image description here

you'll need to create a variable of type object to save the recordset. The you can read that variable in a for loop set to for each ADO enumeration:

enter image description here

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top