How do I modify the column having 2,4,5 as values to 2=active, 4=closd, and 5=inactv in SSIS derived column? (SQL Server DB)
I'm expecting the column should show values.
'active' instead of '2'
'closd' instead of '4'
'inactv' instead of '5'
How do I modify the column having 2,4,5 as values to 2=active, 4=closd, and 5=inactv in SSIS derived column? (SQL Server DB)
I'm expecting the column should show values.
'active' instead of '2'
'closd' instead of '4'
'inactv' instead of '5'
You should use the conditional operator (?:) as follows:
[inputcolumn] == "2" ? "active" :
[inputcolumn] == "4" ? "closed" :
[inputcolumn] == "5" ? "inactive" :
""
My suggestion is to stay away from derived columns and implement the case statement in the database query. Firstly it offloads the execution to the database. Secondly, derived columns are not that easy to work with and we want to keep the number of derived columns (or any number of ssis artifacts for that matter) as low as possible.
your data
first use
string_split
andCross apply
for split string, second usejoin
with equivalent table and third usestring_agg
as follows:dbfiddle