Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to perform a "LIKE" statement in a SSIS Expression?

I'm using a Derived Column Task to change column data using a CASE WHEN statement. However, I need to be able to say..

SQL CODE WOULD BE:

CASE WHEN Column01 LIKE '%i%' THEN '0' ELSE '1' END


In SSIS Expression Language that would be:

[Column01] == "i" ? "0" : "1"  (that's for equals i, not, LIKE %i%.


Is it possible to use a LIKE operator?

like image 951
iamtheratio Avatar asked Jan 19 '11 18:01

iamtheratio


People also ask

How do I use expressions in SSIS?

SSIS Expression Task: creates and evaluates expressions that set variable values at runtime. Variables: can be evaluated as an expression. Task properties: several properties can be set as expression so they can change at runtime More information at Use Property Expressions in Packages.

What are the SSIS expressions?

An expression is a combination of symbols-identifiers, literals, functions, and operators-that yields a single data value. Simple expressions can be a single constant, variable, or function. More frequently, expressions are complex, using multiple operators and functions and referencing multiple columns and variables.

IS NULL expression in SSIS?

SSIS REPLACENULL Syntax and Example If it is not NULL, expression1 itself is returned. If both are NULL, NULL is returned. If the data types of both arguments are different, SSIS will try to convert the data type of the 2nd expression to that of the 1st expression.


2 Answers

I know it is an old question, but these days I found a good answer on web.

If you want a expression for Contains like '%value%' you could use :

FINDSTRING(col, "value", 1) > 0`

If you want a expression for Start with like 'value%' you could use :

FINDSTRING(col, "value", 1) == 1

And finally, if you want a expression for End with like '%value' you could use :

REVERSE(LEFT(REVERSE(col), X))  == "value"

More details look this useful resource : Basic SSIS Equivalents to T-SQL's LIKE

like image 159
Guilherme de Jesus Santos Avatar answered Sep 23 '22 11:09

Guilherme de Jesus Santos


I believe you'll want to use the FINDSTRING function.

FINDSTRING(character_expression, searchstring, occurrence)

...

FINDSTRING returns null if either character_expression or searchstring are null.

like image 41
Conspicuous Compiler Avatar answered Sep 21 '22 11:09

Conspicuous Compiler