SQL Server Import wizard fails with incomprehensible message - sql-server

I just want to import two columns from a flat file into a new table. I have set one column, 'Code', to be varchar(50), and another column, 'Description', to be nvarchar(max).
The import fails with the following messages:
- Executing (Error)
Messages
Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column "Description" 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 "Description" (14)" failed because truncation occurred, and the truncation row disposition on "output column "Description" (14)" 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\rinaldo.tempo\Desktop\ICD10_Edition4_CodesAndTitlesAndMetadata_GB_20120401.txt" on data row 3.
(SQL Server Import and Export Wizard)
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "Source - ICD10_Edition4_CodesAndTitlesAndMetadata_GB_20120401_txt" (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)
The error message suggests to me that data is getting truncated as it's being placed in the 'Description' column, which is of type nvarchar(max)! Having eyeballed the input data, I would say the descriptions are never more than around 2 or 300 characters, so this is out of the question.
Can anyone suggest what is wrong here?

The default size for string columns, in the import, is 50 characters. This truncation happens before data goes to your database.
You should adjust this in the first step of the Import Wizard, in the Columns section.

The error
"Text was truncated or one or more characters had no match in the target code page."
may occur EVEN when your source flat file is a Unicode file and your target column is defined as nvarchar(max).
SSIS infers data types in the source file from scanning a limited number of rows and making an educated guess. Due to endlessly repeated attempts to get it to work, it parked the metadata for the data type OutputColumnWidth to 50 characters somewhere along the way, causing truncation internal to the package.
Look into the metadata in the Data Source's "Advanced" tab to resolve the problem.

you cam also try this .
select all the nvarchar columns as Dt_NTEXT in the advance TAB and then in the data conversion ,select DT_WSTR (Unicode_String) for the Alias Column for all the Nvarchar data Fields.
It worked for me :). Try it

I got this message as well while trying to load a 275 column table. No matter what I did, I couldn't get the message to go away. Changing one column at a time was really difficult. Fix one, get an error in another. Plus some would not seem to fix.
Then I removed all ":" and "," characters from the tab delimited source file, and it loaded just fine.

Related

Mircrosoft SQl Database Large Import Error: 0xc02020a1

I'm trying to import a large csv file into Microsoft Sql Server Management Studio through the 'Import and Export" Wizard.
Data in Question, it's the "Parcels - Comma-Separated Values" csv file
When I try to Import it just as is these are the errors given
Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column "LEGAL_DESC" 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 - parcels_csv.Outputs[Flat File Source Output].Columns[LEGAL_DESC]" failed because truncation occurred, and the truncation row disposition on "Source - parcels_csv.Outputs[Flat File Source Output].Columns[LEGAL_DESC]" 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\tobyr\OneDrive\Desktop\RealEstate\Data\parcels.csv" on data row 13.
(SQL Server Import and Export Wizard)
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Source - parcels_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)
I tried cleaning it up, replacing out the 'None' with just spaces (maybe SQL manger doesn't know 'none'= 'NULL'), using the suggested types, increasing 'headers rows to skip', changing the 'header rows delimiter' to comma. These are the results after just cleaning it up as described above (It's giving me all checkmarks during the review tab:
Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column "SITUS_ADDR_NBR_SUFFIX" 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 "Source - denParcels4_csv.Outputs[Flat File Source Output].Columns[SITUS_ADDR_NBR_SUFFIX]" failed because error code 0xC0209084 occurred, and the error row disposition on "Source - denParcels4_csv.Outputs[Flat File Source Output].Columns[SITUS_ADDR_NBR_SUFFIX]" 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 0xc0202092: Data Flow Task 1: An error occurred while processing file "C:\Users\tobyr\OneDrive\Desktop\RealEstate\Data\denParcels4.csv" on data row 2.
(SQL Server Import and Export Wizard)
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Source - denParcels4_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)
I have also tried setting it to ignore all error but it's just creating an empty table. And creating and empty table and using the 'BULK INSERT' query, but nothing has worked.
You might find it easier to
remove constraints from the target table
set string columns sizes to a larger size
calibrate the import process to use text qualifier on strings (")
Probably not critical - but a quick review of record two in file https://www.denvergov.org/media/gis/DataCatalog/parcels/csv/parcels.csv has an empty value in the first column - SCHEDNUM - perhaps the target table has "not null" constraint
I believe the other errors are related to perhaps non use of text qualifiers- some records have strings wrapped in quotes
If you are tied to the target table maintaining constraints - then long process suggestion ahead - see below
THanks
In this circumstance I would port the file to a new [staging] table that does not have any constraints (e.g. not null). I would also use a text qualifier when importing the data into the fresh table. To avoid all reasonable doubt - set string columns on the [staging] table to a reasonable size - nvarchar (255)
I'd suggest using bcp for the quick fire a file into a temporary [staging] table as it does not require much configuration to lift and shift a text file straight to table - as long as there are the same number of columns in the table as there are delimited values in the file record
bcp also provides facility to progress even if there are errors - default allow 10 errors and skip.
Once all loaded into [staging] table - create an identical table structure as the target - just with no rows.
Then build a merge statement to sweep "good" records from staging table and insert into the target table and use the capability of merge statement to load failed records into a failures table (or perform a not exists)

Constant "potential loss of data" errors when importing Salesforce Dataloader CSV using SQL Import Tool

I have exported a list of accounts from Salesforce using their Dataloader tool. The output file is a CSV file. I have the table I want it imported into already created. I was using nvarchar(255) for all fields, but after I kept getting truncation errors I changed to nvarchar(max).
I am using the SQL Import Tool, and importing a flat file. I set it up with " for text qualifier, and comma separated. Everything looks good. Then when I go to import I kept getting truncation errors on nearly every field.
I went back and had it suggest type, and had it read the entire file.
I kept getting the same errors.
I went back and changed everything to DT_STR with length 255, and then instead of truncation errors, I get the following:
- 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)
I went back AGAIN and changed everything to Stream Text. It's now working, but it's runningslow. What took less than a minute before will take probably 2 hours now.
FYI, I tried to import the csv into Excel but it either cuts off preceeding zeros, or completely screws up the parsing.
What I ended up doing is importing the .csv as Flat File not the .xsl file.
In the Advanced area I highlighted all of the columns on the right side and select DT_STR(255)
The few fields I had that were longer than 255 I changed to D_TEXT
This is a workaround, it is not the "Proper" way to do it, but the "Proper" was just wasn't working due to bad data in the Salesforce Export. Once I got the data into the database I was able to review a lot easier and allowed me to identify the bad data.

Import DAT file content to SQL Server table using Import Export Wizard - Error

I have .DAT file which looks like below format[no column name or header, only data]: || is the separator; so, I have 20 fields.
worth||8000||AC8000||Tal||100||IN||O||2014-01-09 00:00:00||||N||N||N||Y||2014-01-09 00:00:00||Y||19991011||N||Internal||||N
My SQL DB table also has 20 columns.
When I'm using import export wizard, I'm getting error as below:
- Executing (Error)
Messages
Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column "Column 0" 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 0" (10)" failed because truncation occurred, and the truncation row disposition on "output column "Column 0" (10)" 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 "H:\servername\Account.20151201.dat\Account.20151201.dat" on data row 109.
(SQL Server Import and Export Wizard)
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "Source - Account_20151201_dat" (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)
Note: I have all columns in DB table has 255 char.
Please let me know, how to resolve this problem? How can I successfully import it to my DB.
Configure your flat file source with the correct data type and data length. Seems that data received from the file is more than the data length you have defined leading to truncation.
Your first error shows the text you are trying to import in one of the columns is larger than the size of the column in your data base(in destination db table),
So change the column size to be larger in your DB:
ALTER your TABLE, set more characters for the column VARCHAR(255),
For the second error it seems maybe some of row in you DAT file have less or more than 20 columns which don't match with your table, may bi in row 109 as reported in one of the error.
Hope it helps

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.

Operation stopped while importing CSV file into SQL server

I am trying to import CSV file to SQL server database, with no success. I am still newbie to sql server.
Operation stopped...
Initializing Data Flow Task (Success)
Initializing Connections (Success)
Setting SQL Command (Success)
Setting Source Connection (Success)
Setting Destination Connection (Success)
Validating (Success)
Messages
Warning 0x80049304: Data Flow Task 1: Warning: Could not open global shared memory to communicate with performance DLL; data flow performance counters are not available. To resolve, run this package as an administrator, or on the system's console.
(SQL Server Import and Export Wizard)
Prepare for Execute (Success)
Pre-execute (Success)
Messages
Information 0x402090dc: Data Flow Task 1: The processing of file "D:\test.csv" has started.
(SQL Server Import and Export Wizard)
Executing (Error)
Messages
Error 0xc002f210: Drop table(s) SQL Task 1: Executing the query "drop table [dbo].[test]
" failed with the following error: "Cannot drop the table 'dbo.test', because it does not exist or you do not have permission.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
(SQL Server Import and Export Wizard)
Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column ""Code"" 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 ""Code"" (38)" failed because truncation occurred, and the truncation row disposition on "output column ""Code"" (38)" 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 "D:\test.csv" on data row 21.
(SQL Server Import and Export Wizard)
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "Source - test_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)
Copying to [dbo].[test] (Stopped)
Post-execute (Success)
Messages
Information 0x402090dd: Data Flow Task 1: The processing of file "D:\test.csv" has ended.
(SQL Server Import and Export Wizard)
Information 0x402090df: Data Flow Task 1: The final commit for the data insertion in "component "Destination - test" (70)" has started.
(SQL Server Import and Export Wizard)
Information 0x402090e0: Data Flow Task 1: The final commit for the data insertion in "component "Destination - test" (70)" has ended.
(SQL Server Import and Export Wizard)
Information 0x4004300b: Data Flow Task 1: "component "Destination - test" (70)" wrote 0 rows.
(SQL Server Import and Export Wizard)
"Text was truncated or one or more
characters had no match in the target
code page."
may occur EVEN when:
your source flat file is a UNICODE file
AND
your target column is defined as nvarchar(max).
This took me a while to figure out.
Cause
SSIS infers data types in the source file from scanning the first N rows and making an educated guess. Due to endlessly repeated attempts to get it to work, it had parked the metadata for the data type (OutputColumnWidth) to 50 characters somewhere along the way, causing truncation internal to the package.
Resolution
Fiddling with the metadata in the Data Source's "Advanced" tab is then what you want to do to resolve the problem. Try to reset the whole thing by playing with the settings in "Suggest Types", or tweak settings on a field-by-field basis. A truly discouraging amount of iterations was needed in my case (broad input file), but eventually you can get it to work.
You really have two major problems in your import:
Error 0xc002f210: Drop table(s) SQL
Task 1: Executing the query "drop
table [dbo].[test] " failed with the
following error: "Cannot drop the
table 'dbo.test', because it does not
exist or you do not have permission.".
It seems like you're trying to drop a table that doesn't even exist. Solution: just don't do it!
Error 0xc02020a1: Data Flow Task 1:
Data conversion failed. The data
conversion for column ""Code""
returned status value 4 and status
text "Text was truncated or one or
more characters had no match in the
target code page.".
Your column "Code" obviously is longer than the resulting column that you have in your target table. Check the mappings - maybe this is a very long character string, and the default length for the VARCHAR column in SQL Server is too small. Change the target column's data type to e.g. VARCHAR(MAX) - that gives you 2 GByte of space! That should be enough....
Also it seems that "Code" column contains characters that aren't present in your currently selected code page in SQL Server - can you strip those extra special characters before importing? If not, you might need to use NVARCHAR(MAX) for your target column's data type in order to allow it to use Unicode for its characters (thus supporting even the most exotic of characters in your input string).
I had the same problem:
Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column "target" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".
The solution was to go to "Advanced" and change the column width to 255.
Or you could also check the size of the text by going to advanced, then checking the suggestion, and then convert the string to unicode string. it helps in resolving string related error. I have been facing them a lot recently!
Given the fact that this thing is very fast it is advisable to use Suggested Types and tweak settings on a field by field basis. If you are creating a final table directly you may want to increase the column widths a bit for later data entry. I suggest just counting the number of rows in your import file and scan the whole set as your 'sample'. Anything less could result in errors. The time to tweak it is probably not worth your time.
For "Error 0xc02020a1" my case was solved by changing the cell Format from CSV file side:
(Open the CSV file by excel>>change the cell format from percent to general then save it), that solved my case.

Resources