【问题标题】:SSIS Package - Load CSV File with Pipe (|) as DelimiterSSIS 包 - 使用管道 (|) 作为分隔符加载 CSV 文件
【发布时间】:2020-09-25 06:22:53
【问题描述】:

我正在尝试使用 SSIS 包将 .csv 文件加载到 MS SQL 表中。我的文件有逗号(,)作为数据的一部分,所以我将分隔符更改为管道(|)。我使用双引号(“)作为文本限定符。现在,还有另一行导致包失败。

Person ID|Preferred Name|Last Name|First Name|Title
1111|"John "O.H." Doe"|"Doe"|"John"|"Unknown, Undisclosed"
2222|"Jon Snow"|"Stark"|"Jon Snow"|"The White Wolf"

我对 Jon Snow 没有任何意见,但 John Doe 正在杀了我。

[Flat File Source [8]] Error: The column delimiter for column "Preferred Name" was not found.
[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on Flat File Source 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.

有人可以帮帮我吗?提前致谢!

【问题讨论】:

    标签: csv ssis


    【解决方案1】:

    您的数据中包含文本分隔符,并且没有转义。 "John "O.H." Doe"

    除非您的数据中自然有管道并且听起来您可以控制文件格式,否则只需将分隔符设置为 | 并且没有文本分隔符并称之为好。

    您的源数据应该如下所示,一切都会好起来的

    Person ID|Preferred Name|Last Name|First Name|Title
    1111|John "O.H." Doe|Doe|John|Unknown, Undisclosed
    2222|Jon Snow|Stark|Jon Snow|The White Wolf
    

    【讨论】:

    • 啊,我明白你的意思了。我签入了 excel 文件,果然,它有 (") 作为单元格值的一部分。但是如果我忽略文本限定符,我的 SQL 表会在所有数据周围加载双引号,这是我不想要的。如何处理吗?
    • 谢谢!实际上我无法控制文件格式。我会联系我的客户,看看他们是否可以更改文件生成过程。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多