将日期从DT_STR转换为数据库时间戳 [DT_DBTIMESTAMP] 时出错



我有一个制表符分隔的文件,我正在将其下载到数据库表中。 该表包含数据类型为 nvarchar(50( 的列,但数据类型为 datetime 的日期列。 制表符分隔文件具有DT_STR的所有数据类型。 我将数据类型为 DT_STR 的所有字段转换为 DT_WSTR,但我需要将日期从 ST_STR 转换为数据库时间戳 [DT_DBTIMESTAMP]。 但是,我不断收到以下错误:

[Data Conversion [2]] Error: Data conversion failed while converting column "Reason Code Date" (150) to column "Copy of Reason Code Date" (82).  
The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
[Data Conversion [2]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  
The "Data Conversion.Outputs[Data Conversion Output].Columns[Copy of Reason Code Date]" failed because error code 0xC020907F occurred, and the 
error row disposition on "Data Conversion.Outputs[Data Conversion Output].Columns[Copy of Reason Code Date]" 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.
[SSIS.Pipeline] Error: 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.

转换后,我需要表中的日期列如下所示:

ReasonDate
2018-04-19 00:00:00.000
2019-05-10 00:00:00.000
2018-12-09 00:00:00.000
2018-03-09 00:00:00.000
2018-09-21 00:00:00.000
2018-02-06 00:00:00.000

如何在不出现转换错误的情况下实现这一点?

确定文件中的数据在列表末尾被切断,这使得日期列为空以及遇到错误的原因。 此问题已通过重新创建包含所有日期字段(MM/DD/YYYY 格式(的列表得到解决。 在 SSIS 中,日期已从ST_STR转换为数据库时间戳 [DT_DBTIMESTAMP],当再次运行作业时,日期转换已正确完成(格式为"2018-04-19 00:00:00.000"(,并且作业成功完成。

最新更新