SQL 服务器导入导出向导
SQL Server Import and Export wizard
我正在将 CSV 文件导入现有数据库,但遇到了一些错误
- Executing (Error)
Messages
Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column "supervisor" 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 "Source - loc800members_csv.Outputs[Flat File Source Output].Columns[supervisor]" failed because truncation occurred, and the truncation row disposition on "Source - loc800members_csv.Outputs[Flat File Source Output].Columns[supervisor]" 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 "C:\Users\administrator.WDS\Desktop\loc800members.csv" on data row 83.
(SQL Server Import and Export Wizard)
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Source - loc800members_csv 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)
这是我正在导入的 table 的示例。
这里是主管字段的属性
这是我要导入到的 table 中的列。
i.imgur.com/mD5KlCC.jpg
看起来,数据库中的字段不够长,无法支持您尝试导入的数据。您需要缩短数据或(可能更理想)增加数据库中字段的大小。它看起来像是来自 "supervisor" 列(尽管您可能想仔细检查其他列以确保它不会在其他地方发生)。
简而言之,正在发生的事情是它试图按原样导入所有内容,并最终命中您的 csv 文件中的一个字段,该字段太长而无法正确复制。它不是砍掉剩余的数据(截断),而是抛出错误并有效地放弃。我猜数据库中的字段是具有固定大小的 varchar 或 nvarchar 类型。您应该能够在数据库中增加它的大小以提取数据。您可能还需要修改相关的存储过程(如果有的话),因此数据不会在那里被截断。
您可以在向导中更改字段大小,默认值为 50 个字符,这通常太小。
在 "choose a data source" 屏幕上,在指定文件位置并勾选要更改的任何格式后,单击高级。对于每个字段,您将看到数据类型和输出列宽。将其更改为更大的值。第一次查看文件时,我通常使用 500,直到我可以看到实际大小。要一次更改所有列的大小,请突出显示第一列的名称,然后按住 Shift 键并单击最后一列。然后改变尺寸。
我正在将 CSV 文件导入现有数据库,但遇到了一些错误
- Executing (Error) Messages Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column "supervisor" 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 "Source - loc800members_csv.Outputs[Flat File Source Output].Columns[supervisor]" failed because truncation occurred, and the truncation row disposition on "Source - loc800members_csv.Outputs[Flat File Source Output].Columns[supervisor]" 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 "C:\Users\administrator.WDS\Desktop\loc800members.csv" on data row 83. (SQL Server Import and Export Wizard)
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Source - loc800members_csv 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)
这是我正在导入的 table 的示例。
这里是主管字段的属性
这是我要导入到的 table 中的列。
i.imgur.com/mD5KlCC.jpg
看起来,数据库中的字段不够长,无法支持您尝试导入的数据。您需要缩短数据或(可能更理想)增加数据库中字段的大小。它看起来像是来自 "supervisor" 列(尽管您可能想仔细检查其他列以确保它不会在其他地方发生)。
简而言之,正在发生的事情是它试图按原样导入所有内容,并最终命中您的 csv 文件中的一个字段,该字段太长而无法正确复制。它不是砍掉剩余的数据(截断),而是抛出错误并有效地放弃。我猜数据库中的字段是具有固定大小的 varchar 或 nvarchar 类型。您应该能够在数据库中增加它的大小以提取数据。您可能还需要修改相关的存储过程(如果有的话),因此数据不会在那里被截断。
您可以在向导中更改字段大小,默认值为 50 个字符,这通常太小。
在 "choose a data source" 屏幕上,在指定文件位置并勾选要更改的任何格式后,单击高级。对于每个字段,您将看到数据类型和输出列宽。将其更改为更大的值。第一次查看文件时,我通常使用 500,直到我可以看到实际大小。要一次更改所有列的大小,请突出显示第一列的名称,然后按住 Shift 键并单击最后一列。然后改变尺寸。