2012-08-08T13:31:28.170
文件连接器设置,用于PSV文件是数据库时间戳,具有精度[DT_DBTIMESTAMP2]
SQLServer中的目标列具有
datetime
数据类型。 SQL表的软件包 /内容的结果是DateTime Import:
2012-08-08 00:00:00.000
您会注意到尚未进口分钟/秒。 我必须使用错误的DateTime格式,但似乎已经尝试了所有组合而没有成功。
有人可以将我指向正确的方向吗?
Tl;dr
使用dt_dbtimestamp作为您的类型,并将FastParse设置为true
设置
I创建了一个具有以下行的CSV。由于SQL Server的精度为DateTime的精度为.003ms,因此这将确保任何舍入问题都会浮出水面。
2012-08-08T13:31:28.170
2012-08-08T13:31:28.171
2012-08-08T13:31:28.172
2012-08-08T13:31:28.173
CREATE TABLE [dbo].[datetime2Demo]
(
[EventDate] [datetime2](7) NOT NULL
, [insert_date] [datetime2](7) NOT NULL DEFAULT(current_timestamp)
, [string_type] [varchar](50) NULL
) ON [PRIMARY]
EventDate
database timestamp [DT_DBTIMESTAMP]
然后,右键单击“平面文件源”并选择
Show Advanced Editor
。 On "Input and Ouput Properties" tab, I expanded my Flat File Source Output control and again expanded the Output Columns and then selected my EventDate.在自定义属性下,我将
FastParse
的默认值从false更改为
trueI有一个派生的列,添加了String_type值
(DT_STR,20,1252)"DT_DBTIMESTAMP"
,因此我可以跟踪有效和无效的内容。
i使用了OLE DB目标,并将其连接到我创建的表。逆转 选择eventdate,string_type来自dbo.datetime2demo
EventDate string_type
2012-08-08 13:31:28.0000000 DT_DBTIMESTAMP2
2012-08-08 13:31:28.0000000 DT_DBTIMESTAMP2
2012-08-08 13:31:28.0000000 DT_DBTIMESTAMP2
2012-08-08 13:31:28.0000000 DT_DBTIMESTAMP2
2012-08-08 13:31:28.0000000 DT_DATE
2012-08-08 13:31:28.0000000 DT_DATE
2012-08-08 13:31:28.0000000 DT_DATE
2012-08-08 13:31:28.0000000 DT_DATE
2012-08-08 00:00:00.0000000 DT_DBDATE
2012-08-08 00:00:00.0000000 DT_DBDATE
2012-08-08 00:00:00.0000000 DT_DBDATE
2012-08-08 00:00:00.0000000 DT_DBDATE
2012-08-10 13:31:28.0000000 DT_DBTIME2
2012-08-10 13:31:28.0000000 DT_DBTIME2
2012-08-10 13:31:28.0000000 DT_DBTIME2
2012-08-10 13:31:28.0000000 DT_DBTIME2
2012-08-08 13:31:28.1700000 DT_DBTIMESTAMP
2012-08-08 13:31:28.1710000 DT_DBTIMESTAMP
2012-08-08 13:31:28.1720000 DT_DBTIMESTAMP
2012-08-08 13:31:28.1730000 DT_DBTIMESTAMP
我曾经有一个类似的情况,而问题出现在我的消息来源,而不是在目的地上。I suggest you to check the field on the SourceComponent by right clicking it, selecting Show Advanced editor -> input and Output properties -> Expand "Output columns" -> Select your column and change to the proper data type (usually [DT_DBTIMESTAMP] works fine for me).同样为了测试,请在“输出列”上执行相同的操作