SSIS 派生列表达式错误

SSIS Derived Column error on expression

我有一个 SSIS 包,其中有四个不同的数据流任务。每个数据流任务(例如,A、B、C、D)都具有相同的派生列表达式,并将来自不同 oledb 源的结果附加到相同的 oledb 目标。

对于单独的数据流任务 C,我收到如下错误,并且对于 A、B 和 D 都没有问题,尽管它们都具有相同的派生列表达式。

派生列表达式:

 (DT_NUMERIC,18,2)SUBSTRING([Work item /Submission no#],4,2) == (DT_NUMERIC,18,2)SUBSTRING([Work item /Submission no#],4,2) ? LEFT([Work item /Submission no#],15) : LEFT([Work item /Submission no#],16)

C 的数据流任务上显示的 SSIS 错误:

[Derived Column [100]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Derived Column" failed because error code 0xC0049064 occurred, and the error row disposition on "Derived Column.Outputs[Derived Column Output].Columns[SubmissionCommon]" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.

首先,我假设您正在使用 (DT_NUMERIC,18,2)SUBSTRING([Work item /Submission no#],4,2) == (DT_NUMERIC,18,2)SUBSTRING([Work item /Submission no#],4,2) 来检查 SUBSTRING([Work item /Submission no#],4,2) 是否为数字。

我认为您使用的表达式可能会由于使用了转换操作而引发错误。因为如果 SUBSTRING([Work item /Submission no#],4,2) 不是数字,它会抛出错误。

只要按照我对这个问题的回答来解决:

我已经回答过了:

如果您更喜欢 c# 脚本组件(确保添加输入和输出列):

string test = Row.YourRowToTest;
int someNum; //catches output

Row.ColumnName = int.TryParse(test.Substring(4,2),out someNum) == false
                 ?test.Substring(1, 16)
                 :test.Substring(1, 15);