Mircrosoft SQl Database Large Import Error: 0xc02020a1 - sql-server

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)

Related

How to resolve error importing CSV files into SQL Server

I keep getting error messages while trying to import data into SQL Server.
What I have tried:
Used the 'suggest type' button under advanced
Changed the data type from string[DT_STR] to text stream [DT_TEXT]
Changed 'OutputColumn' of problematic columns to VARCHAR 255 and 50
Below is the error message I keep getting:
Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column "start_station_name" 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 - 2021_08_divvy_tripdata_csv.Outputs[Flat File Source Output].Columns[start_station_name]" failed because truncation occurred, and the truncation row disposition on "Source - 2021_08_divvy_tripdata_csv.Outputs[Flat File Source Output].Columns[start_station_name]" 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\USER\Downloads\divvy_trips_data\2021_08_divvy_tripdata.csv" on data row 1828.
(SQL Server Import and Export Wizard)
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Source - 2021_08_divvy_tripdata_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)
It appears the destination column start_station_name is not large enough to hold the data from source, causing a truncation to occur.
You could change the data type in the destination table to nvarchar(max) and run the import again. Assuming that is the only column with that issue it should import.

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: Data import errors

I'm trying to import a data set into SQL server and I keep on getting the errror meesages below. I'm not sure what they mean or how to resolve the issue. Its an excel/csv file so I thought there may be line feeds that were causing the issue but I ran the excel clean function on the fields and im still getting the error.
Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column "Column 4" 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 4" (26)" failed because truncation occurred, and the truncation row disposition on "output column "Column 4" (26)" 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 "Z:\MandA\x.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 - x_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)
The data types are annoyingly different than those in MS SQL, instead of VARCHAR(255) it's DT_STR and the output column width can be set to 255. For VARCHAR(MAX) it's DT_TEXT.
So, on the Data Source selection, in the Advanced tab, change the data type of any offending columns from DT_STR to DT_TEXT (You can select multiple columns and change them all at once).

Combining Multiple Tables Into 1 In SQL Server

I have about 40 tables worth of data that I need to turn into one large table in SQL Server. They are currently text files. I tried combining them all into an Access DB then uploading to SQL Server that way, but their datatypes, nvarchar(255) are far too large and I need them to be smaller, but I cannot edit data types once the table is uploaded so I need to create a new table, then one by one upload the data into it. I cannot figure out the process to import data to an already made table though. Any help would be greatly appreciated.
I tried the regular way of importing but I keep getting the following 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.".
Error 0xc020902a: Data Flow Task 1: The "output column ""Description"" (26)" failed because truncation occurred, and the truncation row disposition on "output column ""Description"" (26)" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.
Error 0xc0202092: Data Flow Task 1: An error occurred while processing file "C:\Users\vzv7kqm\Documents\Queries & Reports\UPSU Usage\UpTo1999.CSV" on data row 9104.
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "Source - UpTo1999_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.
Why not export the data from MS Access to MS SQL Server? Nvarchar(255) just means that it is of variable length. At most, it uses 2 bytes for over head. At worst, I can store 255/2 characters. It is using UNICODE. Why not use VARCHAR(255)?

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