简体   繁体   中英

Importing csv file to table

I'm trying to import a csv file to a table in sql server 2005 with the wizard. but when i import the file is always give me this errors :

Executing (Error) Messages Error 0xc02020a1: Data Flow Task 1: Data conversion failed. 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.". (SQL Server Import and Export Wizard)

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. 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:\\PEP_ENTITIES_71.csv" on data row 1. (SQL Server Import and Export Wizard)

Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "Source - PEP_ENTITIES_71_csv" (1) 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)

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) . 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. Perhaps you need to increase the size of your fields in your SQL table?

Have you tried to import a single, very small line of data from the CSV to see if that works? If it does, excessively large data somewhere in the rest of the sheet may be the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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