【问题标题】:Converting VARCHAR to DATE in SSIS在 SSIS 中将 VARCHAR 转换为 DATE
【发布时间】:2020-03-11 17:43:18
【问题描述】:

我在 SSIS 包中有一个数据流任务,该任务将数据从平面文件加载到表中。

在源数据中,有一个格式为 DD/MM/YYYY 的日期列,我正在尝试将其转换为 YYYY-MM-DD 并将其转换为日期。我的派生列任务中的表达式是:

(DT_DATE)(SUBSTRING(SaleDate,7,4) + "-" + SUBSTRING(SaleDate,4,2) + "-" + SUBSTRING(SaleDate,1,2))

但是此任务失败并出现以下错误:

Error: 0xC0049064 at Load into Staging, Derived Column [2]: An error occurred while attempting to perform a type cast.
Error: 0xC0209029 at Load into Staging, 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[SaleDate2]" 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 Load into Staging, 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 Load into Staging, Flat File Source [12]: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.
Error: 0xC0047038 at Load into Staging, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on Flat File 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.

这是我的表达式编辑器:

我知道这可能是一个很常见的问题,但在寻找答案时我没有找到任何帮助。

我是否遗漏了一些明显的东西?

【问题讨论】:

标签: sql-server tsql ssis


【解决方案1】:

我自己最终发现了这个问题,在将数据查看器附加到派生列任务后,我意识到日期列在源文件中有双引号。我调整了我的 SUBSTRING 参数以进行补偿,现在导入工作正常。

【讨论】:

  • 听起来您实际上应该做的是在您的平面文件连接中指定文本限定。那么这个值就不会用引号括起来了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-27
  • 1970-01-01
  • 2021-08-30
  • 2019-07-15
  • 2014-01-19
  • 1970-01-01
相关资源
最近更新 更多