Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write SSIS switch/case expression?

This is a SQL Server Integration Services (SSIS) expressions question (I'm pretty new to it).

I would like to write a switch/case expression in a Derived Column transform - basically the new column can have 5 different possible values, based on the value of an input column. All I got from Google is the (condition) ? (true value) : (false value) technique, but this only provides for two possible values. Does SSIS expressions have a switch/case type expression?

I thought of using sequential Derived Column transforms, or creating a temporary lookup table, but that just seems more complicated that it really should be.

Thanks.

like image 239
avesse Avatar asked Nov 06 '09 08:11

avesse


People also ask

How do I use expressions in SSIS?

The Expression Task creates and evaluates expressions that set variable values at runtime, using the Expression Builder. When you edit the task, the Expression Builder is launched.

What does == mean in SSIS?

== (Equal) (SSIS Expression) - SQL Server Integration Services (SSIS) | Microsoft Learn.

Why do we use expressions in SSIS?

In Integration Services, expressions can be used to define conditions for CASE statements, create and update values in data columns, assign values to variables, update or populate properties at run time, define constraints in precedence constraints, and provide the expressions used by the For Loop container.


1 Answers

I have used the equivalent of a if-elseif-else statement to solve the problem, like this:

(condition1) ? (true value1) : (condition2) ? (true value2) : (false value)

like image 155
avesse Avatar answered Nov 07 '22 07:11

avesse