Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to use if else in flat file connection Expre

Author  Topic 

ashuthinks
Starting Member

8 Posts

Posted - 2011-09-19 : 04:34:56
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...

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-19 : 05:12:54
you need to use conditional operator like below
(condition)?(true part):(false part)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -