关于 SSIS 包:SSIS 包 – 以管道 (|) 作为分隔符加载 CSV 文件

SSIS Package - Load CSV File with Pipe (|) as Delimiter

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

1
2
3
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 正在杀了我。

1
2
[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.

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


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

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

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

1
2
3
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