Import Failing on Truncation, Even With Ignore on Truncate Set - sql-server

I am importing a huge csv file into SQL Server using Import Wizard. In the Review Data Type Mapping section, all columns are set to "use glocal" for error and truncation. The globals for both are set to ignore. Despite this, the process errors out. Whn I look at the error report, I see:
"The data conversion for column "[col]" returned
status value 4 and status text "Text was truncated or one or more
characters had no match in the target code page."
The column data type is set to nvarchar(255) so it should handle unicode. If the column length is not long enough, it should not be failing, as I specifically set it to ignore truncation.
What's going on here???
.

Related

Text Was Truncated or One or More Characters Has No Match in the Target Code Page

For the life of me, I cannot seem to get past the following error:
Error: 0xC020901C at Import Data - APA, APA Workbook [2]: There was an error with APA Workbook.Outputs[Excel Source Output].Columns[Just] on APA Workbook.Outputs[Excel Source Output]. The column status returned was: "Text was truncated or one or more characters had no match in the target code page.".
Error: 0xC020902A at Import Data - APA, APA Workbook [2]: The "APAC Workbook.Outputs[Excel Source Output].Columns[Just]" failed because truncation occurred, and the truncation row disposition on "APA Workbook.Outputs[Excel Source Output].Columns[Just]" specifies failure on truncation. A truncation error occurred on the specified object of the specified component."
I have an SSIS package that is trying to load data from an Excel file into a SQL Server table. I understand SSIS takes a "Snapshot" of the data and uses this to build the column sizes. My database column for this column is: nvarchar(512).
So some things I have done to try and rectify this are as follows:
Added "IMEX=1" to the extended properties of the Excel Connection string
Created an Excel file with 10 rows and each row has 512 characters in this "Just" column so that SSIS will recognize the size
Went into the Advanced Editor for the Source, then "Input and Output Properties". Then went to the Just column and changed DataType to "Unicode String [DT_WSTR] and changed the Length to 512
After I did the above, I ran the code and the 10 rows of data were imported with no issue. But when I run it against the real Excel file, the error appears again.
I have found that if I add a column to find the character length of the column, then sort by that, putting the largest first, the code works. But if the file is as sent by the user, it errors out
I would appreciate any help on how to solve this, as all of my Google searches state the above would work, but unfortunately it is not.

SQL Import Wizard - Error

I have a CSV file that I'm trying to import into SQL Management Server Studio.
In Excel, the column giving me trouble looks like this:
Tasks > import data > Flat Source File > select file
I set the data type for this column to DT_NUMERIC, adjust the DataScale to 2 in order to get 2 decimal places, but when I click over to Preview, I see that it's clearly not recognizing the numbers appropriately:
The column mapping for this column is set to type = decimal; precision 18; scale 2.
Error message: Data Flow Task 1: Data conversion failed. The data conversion for column "Amount" 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)
Can someone identify where I'm going wrong here? Thanks!
I believe I figured it out... the CSV Amount column was formatted such that the numbers still contained commas separating at the thousands mark. I adjusted XX,XXX.XX to XXXXX.XX it seems to have worked. –

issues importing .tsv to sql Server

I am trying to simply import a .tsv (200 column, 400,000 rows) to Sql Server.
I get this error all the time (always with a different column):
Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column "Column 93" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".
Even though I explicitly:
So, I found myself, going back, and changing the Output (500 for this case):
Is there a way to change all OutputColumnWidth to like ‘max’ at once?! I have 200 columns I can't wait for it to fail and go back and change it for each failed column... (I do not care about performance, any data type is the same for me)
You could try opening the code view of your SSIS package and doing a ctrl-H replace of all "50" to "500". If you have 50's you don't want to change to 500 then look at the code and make the replacement more context-specific.

Import CSV to Microsoft SQL Server 2014 Wizard

I have a very simple (but big) CSV file and I want to import it to my database in Microsoft SQL Server 2014 (Database/Tasks/Import Data). But I receive the following error :
The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data".
Here is a sample of my CSV file (containing ~ 9 million rows) :
1393013,297884,'20150414 15:46:25'
1393010,301242,'20150414 15:46:58'
Ideally my first and second columns are big-int and the third is datetime. In the wizard, I choose 'unsigned 8 byte integer' for first two and 'timestamp' for the third and I receive the error. Even I try to use string for all three columns as data type and still I receive the same error.
I also tried using bcp command in command line. It errs nothing and inserts nothing! Also using "bulk insert" command errors me that :
the column is too long! verify your terminators
But they are correctly fixed!
I appreciate any idea you have as a solution to this simple-looking problem.
You are trying to change the input types: unsigned 8 byte integer is a setting on the source.
You don't need to change source setting at all. 'string [DT_STR]' and the default length of 50 will work.
'timestamp' is a binary type. I believe the type you are after is datetime, but that set is on the destination, not the source. The source is still a string regardless.
You still will not be able to import your date value as a datetime data type.
This would work though (added dashes) -> 2015-04-14 15:46:25. Import what you have as string and fix it after import unless you can get your text file changed.

SSIS Blank Int Flat File Fail on Load

I have an SSIS package I am using to load a Fixed Width flat file. I have put in all the column lengths and have two packages against similar files working correctly. The third however keeps throwing the following error:
[Source 1 [16860]] Error: Data conversion failed. The data conversion for column "Line Number"
returned status value 2 and status text "The value could not be converted because of a
potential loss of data.".
[Source 1 [16860]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.
The "output column "Line Number" (16957)" failed because error code 0xC0209084
occurred, and the error row disposition on "output column "Line Number" (16957)"
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.
After doing some testing this happens for any column I have the is using the DT_I4 Data Type and has a blank in the column. I was going to try using a derived column, but this seems to fail for some of the columns even if I change them to a string data type to handle the blank as a NULL and then do a conversion to an INT later in the data flow.
In the source and the destination task I have the Retain NULL values checkbox ticked however this hasn't changed anything.
Any suggestions on handling this error where INT seems to fail at converting a blank to a NULL?
DT_I4 maps to a four byte signed integer in SSIS.
You were on the right track with your derived column. You just need to add the right expression.
You can try this expression:
ISNULL([Line Number]) ? "0":[Line Number]
This link may also be of use - see the postcode column in the example
http://www.bidn.com/blogs/DonnyJohns/ssas/1919/handling-null-or-implied-null-values-in-an-ssis-derived-column
I ended up using the approach from this blog post:
http://www.proactivespeaks.com/2012/04/02/ssis-transform-all-string-columns-in-a-data-flow-stream/
to handle all of the null and blank columns via a script task and data conversion.

Resources