SSIS - 额外派生列

时间:2013-09-20 11:43:45

标签: sql sql-server sql-server-2008 ssis

如何在SSIS包中转换下面的SQL代码,因为我试图在Extra Derived Column中使用相同的SQL代码,但在这里我收到错误。

SQL代码:

REVERSE(SUBSTRING(REVERSE ([MeasureName]),PATINDEX('% %',REVERSE ([MeasureName])),50))

Please suggest me

Error Msg:

------------------------------

Error at  DRIVE [Extra Derived Columns [1567]]: Parsing the expression "REVERSE(SUBSTRING(REVERSE ([MeasureName]),PATINDEX('% %',REVERSE ([MeasureName])),50))" failed. The single quotation mark at line number "1", character number "52", was not expected.

Error at  DRIVE [Extra Derived Columns [1567]]: Cannot parse the expression "REVERSE(SUBSTRING(REVERSE ([MeasureName]),PATINDEX('% %',REVERSE ([MeasureName])),50))". The expression was not valid, or there is an out-of-memory error.

Error at  DRIVE [Extra Derived Columns [1567]]: The expression "REVERSE(SUBSTRING(REVERSE ([MeasureName]),PATINDEX('% %',REVERSE ([MeasureName])),50))" on "output column "Derived Column 1" (2025)" is not valid.

Error at  DRIVE [Extra Derived Columns [1567]]: Failed to set property "Expression" on "output column "Derived Column 1" (2025)".

------------------------------
ADDITIONAL INFORMATION:

Exception from HRESULT: 0xC0204006 (Microsoft.SqlServer.DTSPipelineWrap)

由于

1 个答案:

答案 0 :(得分:0)

好的,在SSIS中,SSIS中没有PATINDEX你需要使用FINDSTRING`:

FINDSTRING(character_expression, searchstring, occurrence)

返回字符表达式

中指定匹配项的位置

这不会抛出错误,但可能不是你想要的,因为我不知道你试图用你的字符串实现什么:

REVERSE(SUBSTRING(REVERSE([Company]),FINDSTRING("% %",REVERSE([Company]),1),50))