An error occurred while attempting to perform a type cast - sql-server-2008

Hi I am trying to load data from a csv to sql server. The data types in flat file source external and output are (DT_STR,50). I am converting them to their respective data types in a derived column and trying to send all the wrong fields to an error file. But when I am trying to load. I am getting the following error.
Error: 0xC0049064 at Data Flow Task, Derived Column [668]: An error occurred while attempting to perform a type cast.
Error: 0xC0209029 at Data Flow Task, Derived Column [668]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.
The field on which it is failing is 0.234 I am trying to convert it from (DT_STR,50) to (DT_NUMERIC,7,5). I do not understand why this is failing. Please help.

Unfortunately, SSIS throws some pretty generic errors and there are probably dozens of ways you can encounter this one.
I ran into this when I was unaware that my flat file contained a footer that contained a different set of fields than the normal data rows.
I discovered this after I redirected my error rows to a Multicast and enabled the data viewer on my output which let me see what was failing.
In my case, I could see that I had a footer with a reliable value that I could detect with a Conditional Split to skip it. After that, my numeric cast in the derived column behaved correctly.

It's likely that at least one of the values in your (DT_STR,50) field cannot fit (DT_NUMERIC,7,5) because it has more that 7 number characters. Enable a Data Viewer on the path that's inputting into the Data Conversion step and you will probably see what I mean (depending on buffer size, you will likely have to sort on the string field in question). If you don't see one that's too long, buffer though until you do and buffer again, at which time the Data Conversion step will fail.
I had this same error thrown while trying to convert an INT that was too big for the NUMERIC length and precision I was casting to.

Related

SSIS data conversion (from unicode to ANSI) returned status value 4

I have the following problem:
I have an SSIS package that starts with a query executed at an Oracle DB and I would like to export a Fixed Width flat file with ANSI 1253 Code Page. I get an error:
The data conversion for column [column_name] returned status value 4
and status text "Text was truncated or one or more characters had no
match in the target code page"
The problem has to do with the second part of the message, as the width is ok. I tried to use Data Conversion from Toolbox but it didn't work (probably I didn't use it on the right way). I have only select privileges to the database so I cannot add any sql procedures to remove special characters at the query. Also the idea to load data to a staging table wouldn't be the best choice at my case. Does anyone has any idea on how to convert my data without getting this error?
Thanks a lot in advance
Load data using your Source from Oracle DB and keep the data types they are giving you.
add a derived column and cast your column.
(DT_STR,[Insert Length],1252) [columnName]
if the column is ntext you need to do 2 steps to get to string.
(DT_STR...) (DT_WSTR) Ntextcolumn

Bigquery autoconverting fields in data

Background
In Bigquery autodetect,i have following json data being loaded to BQ table.
"a":"","b":"q"
"a":"","b":"q1"
"a":"1","b":"w2"
Now,when this json is uploaded,BQ throws error cannot convert field "a" to integer.
Thoughts
I guess BQ,after reading two rows,BQ infers field "a" as string and then later when "a":"1" comes ,BQ tries to convert it to integer(But why?).
So,to investigate more,i modified the json as follows.
"a":"f","b":"q"
"a":"v","b":"q1"
"a":"1","b":"w2"
Now,when i use this json,no errors,data is smoothly loaded to table.
I don't see as to why in this scenario,if BQ infers field "a" as string,how come it throws no error (why does it not try to convert "a":"1" to integer)?
Query
What i assume is,BQ infers a field to a particular type ,only when it sees data in the field("a":"1" or "a":"f"),but what i don't get is why is BQ trying to automatically converting ("a":"1") to integer when it is of type string.
This autoconversion could create issues.
Please let me know,if my assumptions are correct and what could be done to avoid such errors because realtime data isnot in my control,i can only control my code(using autodetect).
It is a bug with autodetect. We are working on a fix.

String cannot be converted to nvarchar - but everything is already cast to DT_WSTR

I have an SSIS package which has been working for years, and all of a sudden it has stopped working, with the error:
An exception has occurred during data insertion, the message returned from the provider is: The given value of type String from the data source cannot be converted to type nvarchar of the specified target column.
All of my strings are already converted to DT_WSTR in derived columns. Something must have changed in my input flat file format, because it still works on files produced a week ago. I've analysed the difference between the working version and the new failed version in beyond compare, and there are no differences in format or encoding. It has 100+ columns, and with no indication of which column is causing the problem, it is very hard to diagnose.
Any ideas? Thanks
Haha, actually, not all the columns were being case to DT_WSTR. Once I made sure every single field was being cast to DT_WSTR of the appropriate length, the import succeeded.

sql loaded for decimal numbers is going to warning

In my csv file i am having decimal number. I am trying to insert data but the concurrent program is going to warning. In the log Error "Record 1: Rejected - Error on table HR_SAL_DATA_TMP, column CHANGE_PERCENTAGE1.
ORA-01722: invalid number". In my control file i have used DECIMAL EXTERNAL but still it is giving the same error. I would be highly obliged If any one helps me out.
I had similar problem and the reason was mismatched data types in the database. Cross-check the data types of your columns and the ones in datafile
The reason might be connected to NLS settings, try this:
CHANGE_PERCENTAGE1 "TO_NUMBER (:CHANGE_PERCENTAGE1, '999999999D9', 'NLS_NUMERIC_CHARACTERS='',.''')",

SSIS package writing to CRM 2011 Data type error

We are trying to push a single order in to MS CRM (dev instance) via SSIS package.
Most of the columns coming from source (staging table) are of data type 'DT_STR' and their mapped fields in CRM are of 'DT_WSTR' data type.
I already looked for the solution on this site but in all cases the question is for converting wstr to str. In my case I need to convert str to wstr. when I run the package I get error saying,
Column xxxx cannot convert between unicode and non unicode string data type
I have already tried two solution:
1. Right click on the OLE source and convert datatype to wstr and
2. Using 'Data Conversion'
In both cases the error remains the same. Has anyone else had similar issue?
In OLE DB Source properties don't change data types. If you want you can change in
SELECT statement in OLE DB source.
you can change in 'Data Conversion'
Derived Column element
In Derived Column element code is:
(DT_WSTR, 50)([YourString])
Don't replace column, add new column in Derived column element.
You doing something wrong if you can't convert, you don't give real error message (or picture of your design), real error message is in Output window when you execute the package.