【问题标题】:Import DAT file content to SQL Server table using Import Export Wizard - Error使用导入导出向导将 DAT 文件内容导入 SQL Server 表 - 错误
【发布时间】:2016-03-06 02:21:12
【问题描述】:

我有如下格式的 .DAT 文件[没有列名或标题,只有数据]:||是分隔符;所以,我有 20 个字段。

worth||8000||AC8000||Tal||100||IN||O||2014-01-09 00:00:00||||N||N||N||Y||2014-01-09 00:00:00||Y||19991011||N||Internal||||N

我的 SQL DB 表也有 20 列。

当我使用导入导出向导时,我收到如下错误:

 - Executing (Error)
 Messages
  Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column "Column 0" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".
 (SQL Server Import and Export Wizard)

  Error 0xc020902a: Data Flow Task 1: The "output column "Column 0" (10)" failed because truncation occurred, and the truncation row disposition on "output column "Column 0" (10)" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.
 (SQL Server Import and Export Wizard)

  Error 0xc0202092: Data Flow Task 1: An error occurred while processing file "H:\servername\Account.20151201.dat\Account.20151201.dat" on data row 109.
 (SQL Server Import and Export Wizard)

 Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on component "Source - Account_20151201_dat" (1) returned error code 0xC0202092.  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)

注意:我在 DB 表中的所有列都有 255 个字符。

请告诉我,如何解决这个问题?我怎样才能成功地将它导入我的数据库。

【问题讨论】:

    标签: sql-server file import export flat-file


    【解决方案1】:

    使用正确的数据类型和数据长度配置您的平面文件源。似乎从文件接收的数据超过了您定义的数据长度,导致截断。

    您的第一个错误显示您尝试在其中一列中导入的文本大于数据库中列的大小(在目标数据库表中), 因此,将数据库中的列大小更改为更大: 改变你的表,为列 VARCHAR(255) 设置更多字符,

    对于第二个错误,您的 DAT 文件中的某些行似乎与您的表不匹配的列少于或多于 20 列,如其中一个错误所报告的那样,可能在第 109 行。 希望对你有帮助

    【讨论】:

    • 感谢您的回复。我已将第一列的大小设置为 varchar(max)。而对于第二列,它只有 20 个(由 || 分隔)。还有其他想法吗?
    • 请发送目标表的设计,以便我们可以将列与此 DAT 文件进行比较。
    • 也检查一下这可能对你有帮助:stackoverflow.com/questions/1039385/…
    • 感谢您的回复。我已将第一列的大小更改为文本并且它起作用了。
    猜你喜欢
    • 1970-01-01
    • 2010-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多