How to use if else with flat file connection Expression in SSIS?

  • 0 down vote favorite

    share [fb] share [tw]

    I have one SSIS which takes data from .csv file and insert into sql table

    now my file name is

    Flat file properties and expression for connection string is :

    @[User::Directory] + @[User::Filename]+" "+(DT_STR,4,1252)DATEPART( "yyyy" , getdate() ) +"-"+ RIGHT("0" + (DT_STR,4,1252)DATEPART( "mm" , getdate() ), 2) +"-"+ RIGHT("0" + (DT_STR,4,1252)DATEPART( "dd" , DATEADD("day", -1, GETDATE()) ), 2) +".csv"

    which gives me filename like : C:\mytempdata\ACCTMVCHNG_CSV 2011-09-18.csv

    this is yesterdays filename

    but when i run this package on monday the file present is for friday only name will be ACCTMVCHNG_CSV 2011-09-16.csv

    so i want to use if else into this expression

    like if todays day is monday then take fridays file i mean create file path for friday

    like this : C:\mytempdata\ACCTMVCHNG_CSV 2011-09-16.csv

    or else take as it is yesterdays like what i'm doing in above expression...

  • Not saying this is the best way, but it's the way I deal with it... I always avoid having to deal with variable file names by using logic like:

    1 find most recent file in working directory

    2 rename to "processme.xls"

    3 process processme.xls

    4 rename to processed_datetimestamp.xls

    5 move processed*.xls to archivefolder

    6 find next most recent file and start over at 1.

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

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