CASE
WHEN CHARINDEX('%', '{FixedARMRateReductionLimit}') > 0 THEN
CAST(SUBSTRING('{FixedARMRateReductionLimit}', 0,
CHARINDEX('%', '{FixedARMRateReductionLimit}')) as decimal)/100
WHEN '{FixedARMRateReductionLimit}' = 'Weekly PMMS Rate' THEN
PARAM_VAL_TXT
ELSE
.02
END
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
The moral of the following story is that just because you can do something in SSIS, it's not always a good idea.
Case in point, this query. It would be far more efficient to use the existing sql logic to generate the final value than using derived columns or a script task in SSIS (not to mention the waste of pipeline memory, CPU, etc)
Source query
I used the following as a source query.
Find Percent Position
Determine whether a percentage symbol exists in the column. This creates an column called
PercentPosition
Check for rate text
It should be sufficient to do a simple comparison as the first expression shows but I was having issues with it. I assume it's a string conversion/comparison issue (see first Note). Rather than diddle with getting a boolean value, I used findstring to generate the ordinal position.
Derive Output
Enjoy the double usage of the Ternary operator.
You could have simplified some of this in a script task but I'd just do the logic in the source.
This is just to show how the expression should be constructed in the derived transformation. I wouldn't suggest doing it this way since it is very hard to maintain.
Refer @billinkc answer to this question Convert CASE expression in SQL to derived column in SSIS
Here is how the expression should be written in Derived transformation.
Formatted version of the expression.
Sample data used:
Output of derived transformation when viewed in data viewer: