简体   繁体   中英

SQL Server Import and Export wizard

I am importing a CSV file into an existing Database and am getting a few errors

  • 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)

Here is a sample of the table I am importing.

http://i.imgur.com/4zsJqgI.jpg

Here is the properties on the supervisor field

http://i.imgur.com/r5EonQc.jpg

Here are the columns in the table I am importing to.

i.imgur.com/mD5KlCC.jpg

From the looks of it, the fields in the database aren't long enough to support the data that you're trying to import. You'll need to either shorten the data or (probably more ideally) increase the size of the fields in the database. It looks like it's coming from the "supervisor" column (though you might want to double check your other columns to make sure that it doesn't happen elsewhere as well).

In a nutshell, what's happening, is it's attempting to import everything as is, and eventually hitting a field in your csv file that is too long to properly be copied over. Instead of chopping off the remaining data (truncating) it's instead throwing up an error and effectively giving up. I'm guessing the field in the database is a varchar or nvarchar type with a set size. You should be able to just jump the size of this up within the database to pull the data in. You might need to modify relevant stored procedures as well (if there are any), so the data isn't truncated there.

You can change the field size in the wizard, the default is 50 characters which is often too small.

On the "choose a data source" screen, after you have have given the file location and checked off any format things you want to change, then click on advanced. For each field you will see the datatype and output column width. Change it to a larger value. I usually use 500 when looking at a file for the first time until I can see what the actual sizes are. To change all the column sizes at once, highlight the name of the first column and then hold down the shift key and click on the last column. Then change the size.

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