0

what is the SSIS equivalent expression(Derived Column component) of the below SQL expression

cast(CASE WHEN len(cast(KPI as varchar(3))) > 2 THEN 
        CASE substring(cast(KPI as varchar(3)),3,1)
            WHEN 1 then left(cast(KPI as varchar(3)),1) + 'a'
            WHEN 2 then left(cast(KPI as varchar(3)),1) + 'b'
            WHEN 3 then left(cast(KPI as varchar(3)),1) + 'c'
            WHEN 4 then left(cast(KPI as varchar(3)),1) + 'd'
        END
        ELSE cast(KPI as varchar(3))
    END as VarChar(3)) as 'ColumnName'

here Kpi column is a double precision floating point data type...

one major thing i have observed here is LEFT String function is missing from SSIS Expression Builder.

SSIS experts please have a look..

4

1 回答 1

0

我在我的系统上尝试了大约 1 小时..终于找到了答案..希望它对其他人有用

创建了一个新列 NewKPI 并将其转换为数据转换组件中的 dt_str (如 Justin 所述)

(DT_STR,3,1252)(LEN(NewKPI) <= 2 ? NewKPI : (SUBSTRING(NewKPI,3,1) == "1") ? "2A" : (SUBSTRING(NewKPI,3,1) == " 2") ? "2b" : (SUBSTRING(NewKPI,3,1) == "3") ? "2c" : (SUBSTRING(NewKPI,3,1) == "4") ? "2d" : NULL( DT_WSTR,3))

(我使用了子字符串而不是左)

谢谢大家的帮助

于 2014-03-05T15:47:45.470 回答