2014-04-18 115 views
1

这是我第一次体验SSIS,我只是疯了:没有工作
(不要害怕大帖子:大多数只是错误输出。)SSIS:数据类型只是不能从字符串转换

我有两个MS SQL数据库具有相同的字段,我必须从第一个,其中一切都在nvarchar(32 )又名DT_WSTR,第二个,其中类型不同。

数据和它的实例:
时间戳” 是 “DATETIME2(7)” 中的目的地和源看起来像ISO 8601:2013-12-19T00:00:00.000
” 是使用科学记数法的“真实”数字,测试示例为:17e + 10,17.14,17.14e + 5,1715E + 4,1714
四列只有不同的整数(bigint,bigint,tinyint,int)。

现在什么,我已经试过(预警很多报价):

  • 派生列。我使用类似“(DT_DBTIMESTAMP2,7)时间”和“(DT_R4)值”的强制转换。也许我使用的是错误的类型,但是我强烈怀疑:我将它搜索了很多,大多数文章(如this)都告诉我是对的。

Error: 0xC0049064 at Import from ODS to DWH, Derived Column [2]: An error occurred while attempting to perform a type cast.

Error: 0xC0209029 at Import from ODS to DWH, Derived Column [2]: 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[timestamp]" 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 Import from ODS to DWH, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Derived Column" (2) failed with error code 0xC0209029 while processing input "Derived Column Input" (3). 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. Error: 0xC02020C4 at Import from ODS to DWH, OLE DB Source [62]: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.

Error: 0xC0047038 at Import from ODS to DWH, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on OLE DB Source returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.

  • 在源显式改变类型(因此它们匹配目的地),并且直接连接到目的地。

Error: 0xC020901C at Direct, OLE DB Source [32]: There was an error with OLE DB Source.Outputs[OLE DB Source Output].Columns[time] on OLE DB Source.Outputs[OLE DB Source Output]. The column status returned was: "The value could not be converted because of a potential loss of data.".

Error: 0xC0209029 at Direct, OLE DB Source [32]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "OLE DB Source.Outputs[OLE DB Source Output].Columns[time]" failed because error code 0xC0209072 occurred, and the error row disposition on "OLE DB Source.Outputs[OLE DB Source Output].Columns[time]" 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: 0xC0047038 at Direct, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on OLE DB Source returned error code 0xC0209029. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.

  • 数据转换。同样的结果:失败。

Error: 0xC02020C5 at Conversion, Data Conversion [2]: Data conversion failed while converting column "time" (74) to column "Copy of time" (11). The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".

Error: 0xC0209029 at Conversion, Data Conversion [2]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Data Conversion.Outputs[Data Conversion Output].Columns[Copy of time]" failed because error code 0xC020907F occurred, and the error row disposition on "Data Conversion.Outputs[Data Conversion Output].Columns[Copy of time]" 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 Conversion, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Data Conversion" (2) failed with error code 0xC0209029 while processing input "Data Conversion Input" (3). 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.

Error: 0xC02020C4 at Conversion, OLE DB Source [62]: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.

Error: 0xC0047038 at Conversion, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on OLE DB Source returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.

所以,现在我刚跑出的工具和理念如何做到这一点:大多数指令只说一些像“这个到是,它会工作”。我为此付出了很大努力,而且为此我甚至为此创建了一个StackExchange账户。任何帮助赞赏。干杯。

回答

2

此消息

The value could not be converted because of a potential loss of data. 

告诉你你需要知道的几乎一切。您的问题不在于您使用的类型,而在于您的数据来源。

最可能的原因是源代码中至少有一行数据ODS具有无法重新映射(例如)DB_TIMESTAMP格式的值。

我推荐的做法是将所有的源列在你的SQL源语句中明确地转换。

所以不是

select time, value from source 

select (cast time as datetime) as time, (cast value as int) as value from source 

事实上,我会运行此查询针对您的源表,以确保所有的值可以被正确地投在决赛场。 (我的猜测不是或者你不会得到广播错误)

你可以做的另一件事是将你的任务组件从错误“失败”改为“重定向错误行”并将错误行推送到文件目的地所以你可以看到哪些行正在被转换组件踢出。

+0

错误时的重定向 - 如果您从Visual Studio内部运行,您甚至可以将数据查看器附加到它以捕捉实时发生的事情。 –

0

新回答一个老问题 - 但我只是把我所有的头发都试图解决这个错误。多个错误路径,数据转换,派生列等不起作用。两件事解决了这个错误:

我注意到与Null值处理Curreny(DT_CY)时导致错误的列。 我终于通过检查平面文件源节点内的一个小框"Retain null values from source as null values in the data flow"来解决这个错误。 (为什么这个不是选择deafult !?)

其次,我很难将日期转换为字符串 - 一个简单的解决方案将是在控制流中的执行SQL任务内执行更新语句。

例如:您的数据库列为varcharnvarchar。您的来源的数据来自mm/dd/yyyy。无论您尝试多少次与上述错误搏斗,将其转换为字符串都会失败。

我通过加载数据(如果需要,可以使用临时表),然后使用SQL查询转换此列来解决此问题。我亲自使用:

update MY_TABLE_NAME 
set [MY_DATE_COLUMN] = convert(varchar(8),CONVERT (datetime,[MY_DATE_COLUMN]), 112) 
where (FILTER_STATEMENT_TO_UPDATE_ONLY_WHAT_YOU_JUST_LOADED) 

希望这可以帮助其他谁偶然发现这篇文章。

相关问题