使用 dtsx/SSIS 包导入后,SQL Server smalldatetime 列仍为 NULL

SQL Server smalldatetime Column remains NULL after import with dtsx/SSIS package

提问人:Monty Burns 提问时间:11/6/2023 更新时间:11/6/2023 访问量:44

问:

我有一个SQL Server表,我最近在其中添加了一列“TIME_TO_DELETE” - 数据类型为smalldatetime,nullable为true。 通过调用 dtsx 包将数据导入到此表中。数据源是 UTF-8 文件。该文件也已使用新列进行了扩展。平面文件输入列和 OLEDB 目标列之间的映射已到位。数据的格式如下: 2023-11-06 12:00:03. 现在我很清楚 smalldatetime 类型只有小时精度。但我至少希望数据库中输入数据的 YYYY-MM-DD HH 部分。 但发生的情况是,目标表中的列仍为 NULL。我不知道为什么。

在文件连接管理器的编辑模式下预览,输入列的值正确显示。 由于它是文件的最后一列,因此分隔符号会自动配置为 CRLF(与其他列中的分号相反)。

OLEDB 目标中的 KEEP NULLS 选项处于未选中状态。

特别令人困惑的是,倒数第二列(名称:TIMESTAMP_LONG)也是一个 smalldatetime 目标列,并且在输入文件中具有相同的格式。它被正确处理。

  • 目标服务器版本:2022
  • SQL Server 数据库版本:15.0.4326.1
  • 排序规则:Latin1_General_100_BIN2_UTF8
  • IDE:Visual Studio 2019

下面是两个输入文件列的 XML 视图:

    <DTS:FlatFileColumn
      DTS:ColumnType="Delimited"
      DTS:ColumnDelimiter="_x003B_"
      DTS:DataType="133"
      DTS:TextQualified="True"
      DTS:ObjectName="TIMESTAMP_LONG"
      DTS:DTSID="{7D90B042-96D3-48B0-A4EE-F81F440558B4}"
      DTS:CreationName="" 
     />
    <DTS:FlatFileColumn
      DTS:ColumnType="Delimited"
      DTS:ColumnDelimiter="_x000D__x000A_"
      DTS:DataType="133"
      DTS:TextQualified="True"
      DTS:ObjectName="TIME_TO_DELETE"
      DTS:DTSID="{FF5F2959-5C77-4897-A11C-3EE36852CEB5}"
      DTS:CreationName=""
     />

...以及两个输出列的配置(备注:有些表达式可能与英文版VS中出现的表达式不完全相同,因为我们的语言设置全局设置为德语,所以我手动翻译了它们):

    <outputColumn
      refId="Package\Dataflowtask\Flatfilequelle.Outputs[Output of Flatfilesource].Columns[TIMESTAMP_LONG]"
      dataType="dbDate"
      errorOrTruncationOperation="Conversion"
      errorRowDisposition="FailComponent"
      externalMetadataColumnId="Package\Dataflowtask\Flatfilequelle.Outputs[Output of Flatfilesource].ExternalColumns[TIMESTAMP_LONG]"
      lineageId="Package\Dataflowtask\Flatfilequelle.Outputs[Output of Flatfilesource].Columns[TIMESTAMP_LONG]"
      name="TIMESTAMP_LONG"
      truncationRowDisposition="FailComponent">
      <properties>
        <property
          dataType="System.Boolean"
          description="Zeigt an, ob die Spalte die schnelleren gebietsschemaneutralen Analyseroutinen verwendet."
          name="FastParse">false</property>
        <property
          dataType="System.Boolean"
          description="Gibt an, ob die Daten im Binärformat sind."
          name="UseBinaryFormat">false</property>
      </properties>
    </outputColumn>     
    <outputColumn
      refId="Package\Dataflowtask\Flatfilesource.Outputs[Output of Flatfilesource].Columns[TIME_TO_DELETE]"
      dataType="dbDate"
      errorOrTruncationOperation="Conversion"
      errorRowDisposition="FailComponent"
      externalMetadataColumnId="Package\Dataflowtask\Flatfilesource.Outputs[Output of Flatfilesource].ExternalColumns[TIME_TO_DELETE]"
      lineageId="Package\Dataflowtask\Flatfilesource.Outputs[Output of Flatfilesource].Columns[TIME_TO_DELETE]"
      name="TIME_TO_DELETE"
      truncationRowDisposition="FailComponent">
      <properties>
        <property
          dataType="System.Boolean"
          description="Zeigt an, ob die Spalte die schnelleren gebietsschemaneutralen Analyseroutinen verwendet."
          name="FastParse">false</property>
        <property
          dataType="System.Boolean"
          description="Gibt an, ob die Daten im Binärformat sind."
          name="UseBinaryFormat">false</property>
      </properties>
    </outputColumn> 
                

据我所知和我的知识所达到的,我看不出列之间有任何区别,也没有明显的原因TIME_TO_DELETE为什么它仍然是 NULL。 任何帮助将不胜感激。

SQL-Server SSIS 可以为 null 的 smallDateTime

评论

0赞 Xedni 11/6/2023
您能否在源和目标之间放置一个数据查看器,以查看它是否正在从源中移动?
0赞 Cetin Basoz 11/7/2023
使用服务器的某些语言设置,我看到它以这种“2023-11-06 12:00:03”格式失败。您能否暂时将源中的一行更改为“20231106 12:00:03”,看看这是否是问题所在(这应该在 2022 年得到纠正,但谁确切知道)。
0赞 Monty Burns 11/7/2023
@CetinBasoz:我试过这个,它会导致导入崩溃:D
0赞 Monty Burns 11/7/2023
@Xedni我不知道你的确切意思,但我将从包的各个部分上传一些屏幕截图。
0赞 Monty Burns 11/7/2023
不幸的是,图片上传似乎有问题。必须是我公司的防火墙设置或:(

答: 暂无答案