【发布时间】:2015-04-13 06:16:23
【问题描述】:
所以我想从 txt 中导入日期时间:
2015-01-22 09:19:59
使用数据流进入表。我的平面源文件和目标数据库设置得很好。我将高级设置中该列的 txt 输入的数据类型和输入输出属性更改为:
数据库时间戳 [DT_DBTIMESTAMP]
这与用于表的数据库的数据类型相同,因此应该可以工作。
但是,当我执行包时,我收到一条错误消息,提示数据转换失败...我该如何实现?
[Import txt data [1743]] Error: Data conversion failed. The data conversion for column "statdate" returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
[Import txt data [1743]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "output column "statdate" (2098)" failed because error code 0xC0209084 occurred, and the error row disposition on "output column "statdate" (2098)" 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.
[Import txt data [1743]] Error: An error occurred while processing file "C:\Program Files\Microsoft SQL Server\MON_Datamart\Sourcefiles\tbl_L30T1.txt" on data row 14939.
在他给出错误的那一行,日期时间被空格填满。这就是为什么在表格上检查了“允许空值”但我的 SSIS 包由于某种原因给出了错误...我可以在某个地方告诉包也允许空值吗?
【问题讨论】:
-
时间戳日期时间
-
什么意思?它在表本身的数据类型上显示“日期时间”当我检查 OLE DB 目标中的映射时,目标列显示数据库时间戳。这在 DTS 包中工作(我正在转换)-> timestamp = datetime
-
在 SQL Server 中,我们有数据类型 datetime 和 timestamp (msdn.microsoft.com/en-us/library/ms187752.aspx)。抱歉,我没有意识到在 SSIS 中
DT_DBTIMESTAMP映射到datetime,因为命名约定与 T-SQL 不一致。 -
是的,我理解得很好,因为它在 OLE DB 目标的目标列中清楚地表示“数据库时间戳”。您对我的问题可能是什么以及如何解决有什么建议吗?也许数据转换很好,但是由于 txt 文件中某些行上的空格而出现了该错误?我可以将它设置为在任何地方接受特定列中的空值,以防止它在空行上抛出错误吗?
-
您能否将 CSV 的值临时转储到 varchar 字段中,以便查询数据?您可能有类似
2015-02-00...(即无效日期)或2015-02-12 14:37:39.123456(即精度高于数据类型允许...或类似的日期)的日期
标签: sql-server-2008 datetime ssis type-conversion data-conversion