【发布时间】:2020-05-18 10:50:13
【问题描述】:
我使用他们的 Dataloader 工具从 Salesforce 导出了一个客户列表。输出文件是 CSV 文件。我有我希望它导入到已经创建的表。我对所有字段都使用 nvarchar(255),但在不断收到截断错误后,我改为 nvarchar(max)。
我正在使用 SQL 导入工具,并导入一个平面文件。我将其设置为 " 用于文本限定符,并用逗号分隔。一切看起来都很好。然后,当我去导入时,几乎每个字段都出现截断错误。
我回去让它建议输入,然后让它读取整个文件。
我不断收到同样的错误。
我返回并将所有内容更改为长度为 255 的 DT_STR,然后我得到以下内容,而不是截断错误:
- Executing (Error)
Messages
Error 0xc02020c5: Data Flow Task 1: Data conversion failed while converting column "BILLINGSTREET" (86) to column "BILLINGSTREET" (636). The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
(SQL Server Import and Export Wizard)
Error 0xc0209029: Data Flow Task 1: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Data Conversion 0 - 0.Outputs[Data Conversion Output].Columns[BILLINGSTREET]" failed because error code 0xC020907F occurred, and the error row disposition on "Data Conversion 0 - 0.Outputs[Data Conversion Output].Columns[BILLINGSTREET]" 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 "Data Conversion 0 - 0" (552) failed with error code 0xC0209029 while processing input "Data Conversion Input" (553). 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)
我再次返回并将所有内容更改为流文本。它现在正在工作,但运行缓慢。之前不到一分钟的事情现在可能需要 2 个小时。
仅供参考,我尝试将 csv 导入 Excel,但它要么切断前面的零,要么完全搞砸了解析。
【问题讨论】:
-
如果您的列是
nvarchar,为什么您使用DT_STR而不是DT_WSTR?如果DT_STR是正确的,那么为什么您的列不是varchar? -
@Lamu 两个原因... 1,当我第一次通过 Excel 导入它时,导入工具使用 nvarchar 创建了表。我保留它是 nvar char,因为我有几个字段需要超过 400 个字符,而且我们在国际上工作时有一堆字段包含外来字符。保留 nvarchar 比试图找出哪些字段可能有外来字符更容易。
-
@Lamu 我也有浮点、双精度、布尔等,但它一直给我转换错误。我采用了最简单的方法,实际上是有效的。不是应该工作,但确实有效。
-
Excel 选择它们是什么意思?您在使用 CSV 文件之前说过,这意味着您定义数据类型,而不是 Excel(或更具体地说是 ACE 驱动程序)。 CSV 文件和 xlsx 文件完全不同。另一方面,导入过程中的文本文件假定所有数据都是
DT_STR并将创建varchar列。这告诉我您应该使用DT_WSTR,因为您确实有会丢失的字符,以及您收到错误的原因。
标签: sql-server csv import salesforce dataloader