none
Foreach Loop Container in SSIS RRS feed

  • Question

  • I am using for each loop container in ssis. I need to extrat excel file from my folder.
    example file names:- january 2012, march 2012 etc. My problem is i need to extract only current month file (which is October 2012). Any idea?

    pulikondas

    • Moved by Elvis LongModerator Monday, October 29, 2012 9:57 AM better support (From:SQL Server Analysis Services)
    Thursday, October 25, 2012 3:14 PM

Answers

  • Hi Dipsp,

    You can use Expression in Precedence Constraint to achieve your target. We don't have MonthName in SSIS, we can create a variable named VarMonthName and write expression on it to use it where ever we need MonthName, detail steps you can refer to: http://sqlage.blogspot.ch/2011/03/monthname-and-day-name-in-ssis.html, and then you can put the following expression in Precedence Constraint to get current month file only:

    Right( @[User::FileName],4)==(DT_WSTR,4)Year(getdate()) && SUBSTRING( @[User::FileName] ,1, len( @[User::FileName] )-5)==@[User::VarMonthName]

    Thanks,
    Eileen


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.

    • Proposed as answer by King kalyan Wednesday, October 31, 2012 5:16 AM
    • Marked as answer by Eileen Zhao Wednesday, November 7, 2012 12:40 AM
    Wednesday, October 31, 2012 3:02 AM

All replies

  • Hi,

    You have posted your question in the wrong forum.

    BR

    Thomas Ivarsson

    Link to the correct forum is here: http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/threads

    Thursday, October 25, 2012 5:24 PM
  • Hi Dipsp,

    You can use Expression in Precedence Constraint to achieve your target. We don't have MonthName in SSIS, we can create a variable named VarMonthName and write expression on it to use it where ever we need MonthName, detail steps you can refer to: http://sqlage.blogspot.ch/2011/03/monthname-and-day-name-in-ssis.html, and then you can put the following expression in Precedence Constraint to get current month file only:

    Right( @[User::FileName],4)==(DT_WSTR,4)Year(getdate()) && SUBSTRING( @[User::FileName] ,1, len( @[User::FileName] )-5)==@[User::VarMonthName]

    Thanks,
    Eileen


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.

    • Proposed as answer by King kalyan Wednesday, October 31, 2012 5:16 AM
    • Marked as answer by Eileen Zhao Wednesday, November 7, 2012 12:40 AM
    Wednesday, October 31, 2012 3:02 AM