SSIS 派生列表达式 - 删除前导零
SSIS Derived Column Expression - removing leading zeros
我有一个包由于带有数字字符串的负号而失败,例如:
000000000-25.00
派生列表达式为:
ISNULL(wstr_Payment_Amount) || TRIM(wstr_Payment_Amount) == "" ? (DT_CY)0 : (DT_CY)wstr_Payment_Amount
列的数据类型是货币。我在派生列上做了一个重定向行,以确认它是导致失败的负号。
这是我的..
FINDSTRING(wstr_Payment_Amount, "-", 1) >0 ? TRIM(SUBSTRING(wstr_Payment_Amount, FINDSTRING(wstr_Payment_Amount, "0-", 1), 8)) : wstr_Payment_Amount
我正在使用 SSIS 2008
。
如果您使用两个派生列,则在第一个列中将其保留为字符串...
ISNULL(wstr_Payment_Amount) || TRIM(wstr_Payment_Amount) == "" ? (DT_WSTR,100)"0" : (DT_WSTR,100)wstr_Payment_Amount
我认为你真的很接近,但一旦你确定了负号,请考虑以下内容......
FINDSTRING(wstr_Payment_Amount, "-", 1) >0 ? (DT_CY) ("-" + replace(wstr_Payment_Amount,"-","")) : (DT_CY)wstr_Payment_Amount
这只会将“-”移到前面,所有零都会消失。
我有一个包由于带有数字字符串的负号而失败,例如:
000000000-25.00
派生列表达式为:
ISNULL(wstr_Payment_Amount) || TRIM(wstr_Payment_Amount) == "" ? (DT_CY)0 : (DT_CY)wstr_Payment_Amount
列的数据类型是货币。我在派生列上做了一个重定向行,以确认它是导致失败的负号。
这是我的..
FINDSTRING(wstr_Payment_Amount, "-", 1) >0 ? TRIM(SUBSTRING(wstr_Payment_Amount, FINDSTRING(wstr_Payment_Amount, "0-", 1), 8)) : wstr_Payment_Amount
我正在使用 SSIS 2008
。
如果您使用两个派生列,则在第一个列中将其保留为字符串...
ISNULL(wstr_Payment_Amount) || TRIM(wstr_Payment_Amount) == "" ? (DT_WSTR,100)"0" : (DT_WSTR,100)wstr_Payment_Amount
我认为你真的很接近,但一旦你确定了负号,请考虑以下内容......
FINDSTRING(wstr_Payment_Amount, "-", 1) >0 ? (DT_CY) ("-" + replace(wstr_Payment_Amount,"-","")) : (DT_CY)wstr_Payment_Amount
这只会将“-”移到前面,所有零都会消失。