简体   繁体   English

将csv文件导入表

[英]Importing csv file to table

I'm trying to import a csv file to a table in sql server 2005 with the wizard. 我正在尝试使用向导将csv文件导入sql server 2005中的表。 but when i import the file is always give me this errors : 但是当我导入文件总是给我这个错误:

Executing (Error) Messages Error 0xc02020a1: Data Flow Task 1: Data conversion failed. 执行(错误)消息错误0xc02020a1:数据流任务1:数据转换失败。 The data conversion for column "Column 15" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.". “列15”列的数据转换返回状态值4,状态文本“文本被截断,或者目标代码页中的一个或多个字符不匹配”。 (SQL Server Import and Export Wizard) (SQL Server导入和导出向导)

Error 0xc020902a: Data Flow Task 1: The "output column "Column 15" (70)" failed because truncation occurred, and the truncation row disposition on "output column "Column 15" (70)" specifies failure on truncation. 错误0xc020902a:数据流任务1:“输出列”列15“(70)”失败,因为发生了截断,并且“输出列”列15“(70)”上的截断行处置指定了截断失败。 A truncation error occurred on the specified object of the specified component. 指定组件的指定对象上发生截断错误。 (SQL Server Import and Export Wizard) (SQL Server导入和导出向导)

Error 0xc0202092: Data Flow Task 1: An error occurred while processing file "C:\\PEP_ENTITIES_71.csv" on data row 1. (SQL Server Import and Export Wizard) 错误0xc0202092:数据流任务1:在数据行1上处理文件“C:\\ PEP_ENTITIES_71.csv”时发生错误。(SQL Server导入和导出向导)

Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. 错误0xc0047038:数据流任务1:SSIS错误代码DTS_E_PRIMEOUTPUTFAILED。 The PrimeOutput method on component "Source - PEP_ENTITIES_71_csv" (1) returned error code 0xC0202092. 组件“Source - PEP_ENTITIES_71_csv”(1)上的PrimeOutput方法返回错误代码0xC0202092。 The component returned a failure code when the pipeline engine called PrimeOutput(). 当管道引擎调用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) (SQL Server导入和导出向导)

What i'm doing wrong? 我做错了什么? This file was a export from a query, then i delete all records and try to import. 此文件是从查询导出,然后我删除所有记录并尝试导入。

The flat file import task will default lengths to VARCHAR(50) . 平面文件导入任务的默认长度为VARCHAR(50) You need to go to the Advanced property of the flat file connection page and change the length manually to match the destination table. 您需要转到平面文件连接页面的“高级”属性,并手动更改长度以匹配目标表。 There should also be an option to Suggest Types which may match the metadata that you're using, but it does a sampling of rows from the file so it may not be as accurate as just setting types manually. 建议类型也应该有一个选项可以匹配您正在使用的元数据,但它会对文件中的行进行采样,因此它可能不如仅手动设置类型那样准确。

It may be that you're trying to import data from the CSV which is too large for the field you're importing it in to. 您可能正在尝试从CSV中导入数据,这对于您要导入的字段来说太大了。 Perhaps you need to increase the size of your fields in your SQL table? 也许您需要增加SQL表中字段的大小?

Have you tried to import a single, very small line of data from the CSV to see if that works? 您是否尝试从CSV导入一个非常小的数据行,看看它是否有效? If it does, excessively large data somewhere in the rest of the sheet may be the problem. 如果是这样的话,在表格的其余部分某处可能存在过大的数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM