SSIS空白Int平面文件加载失败

时间:2014-11-24 22:14:07

标签: sql-server ssis null type-conversion

我有一个SSIS包用于加载Fixed Width平面文件。我已经放入了所有列长度,并有两个针对类似文件正常工作的包。然而,第三个不断抛出以下错误:

[Source 1 [16860]] Error: Data conversion failed. The data conversion for column "Line Number"
returned status value 2 and status text "The value could not be converted because of a 
potential loss of data.".

[Source 1 [16860]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  
The "output column "Line Number" (16957)" failed because error code 0xC0209084 
occurred, and the error row disposition on "output column "Line Number" (16957)" 
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_I4数据类型并且列中有空白的任何列都会发生这种情况。我打算尝试使用派生列,但是对于某些列来说这似乎失败了,即使我将它们更改为字符串数据类型以将空白处理为NULL然后在数据流中稍后转换为INT

在源和目标任务中,我勾选了“保留NULL值”复选框,但这并没有改变任何内容。

有关处理此错误的任何建议,其中INT似乎在将空白转换为NULL时失败了吗?

2 个答案:

答案 0 :(得分:1)

DT_I4映射到SSIS中的四字节有符号整数。

您使用派生列进入正确的轨道。你只需要添加正确的表达式。

你可以尝试这个表达式:

ISNULL([Line Number]) ? "0":[Line Number]

此链接也可能有用 - 请参阅示例中的邮政编码列 http://www.bidn.com/blogs/DonnyJohns/ssas/1919/handling-null-or-implied-null-values-in-an-ssis-derived-column

答案 1 :(得分:0)

我最终使用了这篇博文中的方法:

http://www.proactivespeaks.com/2012/04/02/ssis-transform-all-string-columns-in-a-data-flow-stream/

通过脚本任务和数据转换处理所有空列和空白列。