Importing data from Excel using ForEach Loop

  • Using SSIS to import Excel spreadsheet into SQL Server 2005. Created the package variable for PathAndFileName. Execute package. First Excel file is imported, but 2nd Excel file is not. Reads and imports First Excel file twice. Because there are 2 Excel files in the directory.

    After following the MSDN 345182 How To, received a connection error.

    Any suggestions?

  • Create a string variable and call it currentFile.
    In the For Each Loop editor go to Variable Mappings, in the Variable field select User::currentFile and in the Index field enter 0
    Now modify the Excel Connection Manager properties. select Expressions, in the Property Field select ExcelFilePath, in the Expression field click the ellipsis [...] and drag and drop User:currentFile into the expression window. Click okay to everything and you are done.

  • delaine.gocke - Friday, August 29, 2008 7:38 AM

    Any suggestions?

    BAAA-HAAA!!! Yeah... Do it in T-SQL instead. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply