【问题标题】:Invalid Date Format while using SQL server Export Wizard使用 SQL Server 导出向导时日期格式无效
【发布时间】:2016-10-19 04:52:08
【问题描述】:


我正在尝试将数据从一个 SQL Server 导出到另一个。我有大约 12 个表,其中 11 个已成功导出,但是在一个表中出现问题,它有 2 列为 DateTime,在导出时我遇到了这个异常:

- Copying to [dbo].[ClaimDetails] (Error)
Messages
Error 0xc0202009: Data Flow Task 1: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80004005  Description: "Invalid date format".
(SQL Server Import and Export Wizard)

Error 0xc020901c: Data Flow Task 1: There was an error with Destination -     ClaimDetails.Inputs[Destination Input].Columns[Entrydate] on Destination -   ClaimDetails.Inputs[Destination Input]. The column status returned was:   "Conversion failed because the data value overflowed the specified type.".
(SQL Server Import and Export Wizard)

Error 0xc0209029: Data Flow Task 1: SSIS Error Code   DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  The "Destination -  ClaimDetails.Inputs[Destination Input]" failed because error code 0xC020907A  occurred, and the error row disposition on "Destination -  ClaimDetails.Inputs[Destination Input]" 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.
(SQL Server Import and Export Wizard)

Error 0xc0047022: Data Flow Task 1: SSIS Error Code  DTS_E_PROCESSINPUTFAILED.  The ProcessInput method on component "Destination -  ClaimDetails" (124) failed with error code 0xC0209029 while processing input  "Destination Input" (137). 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.
(SQL Server Import and Export Wizard)

Error 0xc02020c4: Data Flow Task 1: The attempt to add a row to the Data  Flow task buffer failed with error code 0xC0047020.
(SQL Server Import and Export Wizard)

Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.   The PrimeOutput method on Source - ClaimDetails 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 Import and Export Wizard)

它成功复制了大约 4025 行,我有大约 21794 行,所以手动查看每一行有点困难,所以我尝试运行

SELECT
    *
FROM
   ClaimDetails
WHERE
    ISDATE(ActualDate) = 0

在这两个字段上,但它没有显示任何行,所以请告诉我我能做什么。

日期字段格式如下所示

谢谢

【问题讨论】:

    标签: sql-server datetime sql-server-2012 export invalid-argument


    【解决方案1】:

    您应该先设置日期格式。查看您的记录应该是 ymd

        SET DATEFORMAT ymd;
    
    SELECT *
    FROM ClaimDetails
    WHERE ISDATE(ActualDate) = 0
    

    【讨论】:

    • 可能您还需要为目标数据库设置日期格式。
    • 我没有通过这个查询处理数据,但是我应该创建一个具有相同类型的相同列的数据库,然后尝试导出吗?
    • 是的,我明白了。我想说的是保持源日期格式和目标日期格式相同。是的,匹配源列和目标列的数据类型。
    • 抱歉延迟响应,是的,您是对的,目的地的数据类型是日期,源是日期时间,因此已更改并且有效,谢谢
    • Np... 总是 WC :)
    【解决方案2】:

    按日期字段(从最早到最新)对表格进行排序。如果有 Null 值,则滚动到有数据的第一条记录。现在确保年份是正确的年份。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-06
      • 1970-01-01
      • 2018-05-19
      • 1970-01-01
      • 2012-02-29
      • 2017-05-05
      • 2013-04-10
      • 2020-07-17
      相关资源
      最近更新 更多