Vita


I need to get value from one table and if it is (for example) string - TodayDate, I need to change it to "Today Date" with a space in it and use it later in my Data Flow.

So I would need something similar to

If value = "TodayDate" Then

value - "Today Date"

Else

.....

How do I do that

Thanks.





Re: How do I do "If statement" in SSIS?

Wenyang Hu


Check on the Derived Column transform in SSIS dataflow task.







Re: How do I do "If statement" in SSIS?

Jamie Thomson

To add to Wenyang's answer...you will need to use the Conditonal Operator within the Derived Column transform.

: (Conditional) (SSIS)

(http://msdn2.microsoft.com/en-us/library/ms141680.aspx)

Wenyang, I don't thinkyour answer is complete. Do you really think it warrants being marked as an answer Hope you don't mind me asking.

Regards

Jamie







Re: How do I do "If statement" in SSIS?

Vita

How do I create expresiion

Column Name - MonitorType

MonitorType "SA" : @MyVariable

This shows error.

I want to see if the MonitorType field returns "SA" and if yes - use the variable I have.

If it returns for example "BA" use another variable.






Re: How do I do "If statement" in SSIS?

Jamie Thomson

Vita wrote:

How do I create expresiion

Column Name - MonitorType

MonitorType "SA" : @MyVariable

This shows error.

I want to see if the MonitorType field returns "SA" and if yes - use the variable I have.

If it returns for example "BA" use another variable.

MonitorType == "SA" @[MyVariable] : @[SomeOtherVariable]

-Jamie






Re: How do I do "If statement" in SSIS?

Vita

Thanks.






Re: How do I do "If statement" in SSIS?

Jamie Thomson

Please don't forget to mark posts as answered.




Re: How do I do "If statement" in SSIS?

Vita

What if I have more than 2 variables.

If "SA" - var 1,

If BA" - var 2

If "DA" - var 3

If "DS" - var 4

Can I do Else If in the same expression






Re: How do I do "If statement" in SSIS?

Robshobs

I believe you can continue to add additional tests in the Derived Column task.

Rob





Re: How do I do "If statement" in SSIS?

Jamie Thomson

Vita wrote:

What if I have more than 2 variables.

If "SA" - var 1,

If BA" - var 2

If "DA" - var 3

If "DS" - var 4

Can I do Else If in the same expression

Yes. You need to nest the Conditonal Operator.

MonitorType == "SA" @var1 : (MonitorType == "BA" @var2 : (MonitorType == "DA" @var3 : (MonitorType == "DS" @var4 : @SomeDefaultVariable)))

-Jamie

please don't forget to mark as answered.






Re: How do I do "If statement" in SSIS?

Vita

Thanks again. I appreciate it.