locked
Help Needed: For Each Loop RRS feed

  • Question

  • Hi,

    I'm using For Each Loop Container in an SSIS package. I have a folder which has 5 excel sheets and the container will have to read data from those sheets and load into a destination table. I know how the for each loop works but the problem here is this: Each excel has 10 columns like this: "ID", "Name","Process","16-May-11","17-May-11","18-May-11","19-May-11","20-May-11","21-May-11","22-May-11". The next sheet has the first 3 columns same but starting from 4th column the column names are "23-May-11"........,"29-May-11"..Same case for the remaining sheets..

    I am using an UNIPIVOT in my data flow task and when I run the container, it fails and inserts the contents of only the first sheet..My destination table looks like this:

    CosmoID           EmployeeName       Process            Shift              ShiftDate
    M12089             Srinivas                 Premium      0900-2200        2011-05-16
    M12089             Srinivas                 Premium      0900-2200        2011-05-17
    M12089             Srinivas                 Premium      0900-2200        2011-05-18

    My question is does for each loop works in this case?

    Many Thanks,


    Sharath
    Wednesday, July 6, 2011 9:37 AM

Answers

  • Hello Sharath,

    I just want to offer you a good (IMHO) post on how to do something very similar to what you need: http://bi-polar23.blogspot.com/2007/08/loading-multiple-excel-files-with-ssis.html

    Please come back to ask questions if any arise.


    Arthur My Blog
    By: TwitterButtons.com
    Wednesday, July 6, 2011 2:08 PM

All replies

  • Do you want to use the for each loop to loop through the files or to loop through the worksheets?
    Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com
    Wednesday, July 6, 2011 11:32 AM
  • I want the for each to loop through all the excel files. The excel may have more than 1 sheets but the sheet name which hold the required data are the same.
    Sharath
    Wednesday, July 6, 2011 12:27 PM
  • Hello Sharath,

    I just want to offer you a good (IMHO) post on how to do something very similar to what you need: http://bi-polar23.blogspot.com/2007/08/loading-multiple-excel-files-with-ssis.html

    Please come back to ask questions if any arise.


    Arthur My Blog
    By: TwitterButtons.com
    Wednesday, July 6, 2011 2:08 PM