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
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 SSIS Connection String If Statement

Author  Topic 

ZMike
Posting Yak Master

110 Posts

Posted - 2013-03-04 : 16:21:03
Good Afternoon Everyone,

I'm trying to figure out the IF Statement for connections strings.

Basically if

GETDATE() = Monday

I believe I'd use this

RIGHT("0" + (DT_STR,4,1252) DATEPART("DW", GETDATE() ),2) =02

THEN

"/data/TransferData"

+
RIGHT("0" + (DT_STR,4,1252) DATEPART("M", GETDATE()),2)
+RIGHT("0" +

(DT_STR,4,1252) DATEPART("D",DATEADD("D", -3, GETDATE())) ,2)
+
(DT_WSTR, 4) YEAR( GETDATE() )
+
"-"

+
RIGHT("0" + (DT_STR,4,1252) DATEPART("M",GETDATE()),2)
+
RIGHT("0" + (DT_STR,4,1252) DATEPART("D",GETDATE()),2)
+
(DT_WSTR, 4) YEAR( GETDATE() )
+
".csv"

ELSE

"/data/TransferData"

+
RIGHT("0" + (DT_STR,4,1252) DATEPART("M", GETDATE()),2)
+RIGHT("0" +

(DT_STR,4,1252) DATEPART("D",DATEADD("D", -1, GETDATE())) ,2)
+
(DT_WSTR, 4) YEAR( GETDATE() )
+
"-"

+
RIGHT("0" + (DT_STR,4,1252) DATEPART("M",GETDATE()),2)
+
RIGHT("0" + (DT_STR,4,1252) DATEPART("D",GETDATE()),2)
+
(DT_WSTR, 4) YEAR( GETDATE() )
+
".csv"


Can anyone tell me how to achieve this ?


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-03-05 : 00:02:48
can you explain your rules in words first on how you want filename to come?

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

Go to Top of Page

ZMike
Posting Yak Master

110 Posts

Posted - 2013-03-05 : 08:45:59
Visakh16, My file names are actually correct how I have them. On Mondays I instead of "/data/TransferData03032013-03042013.csv I just need to change the getdate -1 to getdate -3 so it pulls Friday - Monday

So on Mondays Getdate -3 as the a starting date, and getdate is always today as a standard.

Tuesday - Friday GetDate()-1 to Getdate
I can totally ignore Saturday and Sunday since thouse are included in the Monday files.

Does that help ?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-03-05 : 08:47:57
yep...do you've a calendar table?

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

Go to Top of Page
   

- Advertisement -