我在将.CSV中的数据转换为数据类型FLOAT列时遇到问题。我试图直接链接它并使用数据转换任务,但(在这两种情况下)它一直告诉我它无法转换:
Error: 0xC02020C5 at DC_Weekly_Cost_Target csv to FatzWklyCst_Target, Data Conversion [156]: Data conversion failed while converting column "Target" (22) to column "Copy of Target" (163). The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
我的研究让我使用派生列转换编辑器。我找到了一些网站,向我介绍了如何正确使用" Expression"部分:
以上是我尝试将字符串(目标和浪费)转换为数据类型Float的方法。我在使用编辑器时没有收到错误消息(即它会让我克服没有错误),但是,当我尝试运行包时收到错误:
Error: 0xC0049064 at DC_Weekly_Cost_Target csv to FatzWklyCst_Target, Map Target in correct datatype 1 1 [222]: An error occurred while attempting to perform a type cast.
Error: 0xC0209029 at DC_Weekly_Cost_Target csv to FatzWklyCst_Target, Map Target in correct datatype 1 1 [222]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "component "Map Target in correct datatype 1 1" (222)" failed because error code 0xC0049064 occurred, and the error row disposition on "output column "Target_Float" (227)" 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.
Error: 0xC0047022 at DC_Weekly_Cost_Target csv to FatzWklyCst_Target, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Map Target in correct datatype 1 1" (222) failed with error code 0xC0209029 while processing input "Derived Column Input" (223). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure.
这是我第一次使用派生列转换编辑器。有谁看到我做错了什么?或者,您对将.csv文件中的数据转换为数据类型为float的列的最佳方法有何建议?我感谢任何人都可以给我的任何帮助。
答案 0 :(得分:2)
你已经尝试过一种合理的方法,但是数据中的某些东西正在被炸毁 - 可能"无效"字符例如$或,
我会用脚本任务替换派生列转换。在那里,您可以利用.NET Framework,例如试试...... Catch,TryParse,Regex。您可以逐行调试代码以检查有错误的行。您还可以使用Reflection将转换代码计算为您调用传递给脚本任务的每个列的函数。
PS:你的目的地无关紧要。