SSIS Blank Int Flat File Fail on Load - sql-server

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.

Related

Derived column failures due to error codes DTS_E_INDUCEDTRANSFORMFAILUREONERROR 0xC0049067 and DTS_E_PROCESSINPUTFAILED 0xC0209029

I've been working on an SSIS package for which I've added derived columns (which I've posted earlier on here). The issue I'm running into is that this child package is running fine in one environment, but for some reason, is failing in my Dev environment.
The errors occurring are:
"SSISError Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "component "DerivedColumn" (9567)" failed because error code 0xC0049067 occurred, and the error row disposition on "output column "SchemaID"(9744)" specifies failure on error" and "SSISError Code DTS_E_PROCESSINPUTFAILED. TheProcessInput method on component "Derived Column" (9567) failed with error code 0xC0209029 while processing input "Derived Column Input"(9568). The identified component returned an error from the ProcessInputmethod".
I've compared the table's fields, particularly SchemaID in both environments and they're identical. I even tried recreating the particular table in Dev and re-tried running the package, to no avail.
This is the Derived Column Transformation Editor screen:
Can anyone please make any suggestions on this? Thank you in advance!
Most probably its bad data that is not being converted through your derived transformation. What would be ideal is to create a test table and change the data type of SchemaID column to varchar and get all the data in there. It will be easier for you to debug the issue. Alternatively, you may want to open the "Advanced Editor" tab for your derived column and change either the data type of input schemaID or the length of it (never mind if its int or something else that doesnt support lengths).
The SchemaId expression is the following:
SUBSTRING((DT_WSTR,15)PCMRetrievalCode,3,FINDSTRING(((DT_WSTR,15)PCMRetrievalCode),"C"C,1) - 3)
I think that the issue is caused by the FINDSTRING function. In case that PCMRetreievalCode column doesn't contains "C" or it will return an index < 3 then FINDSTRING(((DT_WSTR,15)PCMRetrievalCode),"C",1) - 3 will throw an exception because in the SUBSTRING function the length parameter should be positive.
You can add a conditional ? : to solve the issue:
FINDSTRING(((DT_WSTR,15)PCMRetrievalCode),"C",1) >= 3 ? SUBSTRING((DT_WSTR,15)PCMRetrievalCode,3,FINDSTRING(((DT_WSTR,15)PCMRetrievalCode),"C"C,1) - 3) : ""
Another suggestion is to increase the column length more than 13.

Importing CSV in SSIS: truncation error

I am importing a CSV file in SSIS having many string columns. I have set column width more than the maximum length, but still I am getting below errors
[Input CSV File [114]] Error: Data conversion failed. The data
conversion for column "Functionality" returned status value 4 and
status text "Text was truncated or one or more characters had no match
in the target code page.".
[Input CSV File [114]] Error: The "Input CSV File.Outputs[Flat File
Source Output].Columns[Functionality]" failed because truncation
occurred, and the truncation row disposition on "Input CSV
File.Outputs[Flat File Source Output].Columns[Functionality]"
specifies failure on truncation. A truncation error occurred on the
specified object of the specified component.
[Input CSV File [114]] Error: An error occurred while processing file
"D:\Prateek\SSIS_UB_PWS\January.csv" on data row 236.
[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The
PrimeOutput method on Input CSV File 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.
As a work around, I have set values to 500 or 1000 and now it is allowing me to continue, but the actual length is in double digit.
Kindly suggest what could be the possible error.
Check , what is the value of the column 'Functionality' at row number 236. And then , verify what is allowed. In the advanced editor of the source, you can increase the length(if there are not any special characters) if you are loading data into a table
Truncation warning appears when your source column length is bigger than destination column length, so it'll truncate the source value to fit into its destination. Could you share with us the length of the column length, and the length of destination column?
I got the error, sorry for my bad understanding of issue.
Actually one of the column is having multiple commas (,) in data and that was getting into other columns (Text delimiter was set to ). Hence I was getting bigger values than expected in other columns as well.
Thanks for you help!

SSIS Package error- SSIS Error Code DTS_E_PROCESSINPUTFAILED

SSIS job has failed and posting the below error
[Product Sales [749]] 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 float of the specified target column.
[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Product Sales" (749) failed with error code 0xC020844B while processing input "ADO NET Destination Input" (752). 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.
Can some one please advise if you have come across this kind of error
Thank you
Your error message is explaining the issue to you: "The given value of type String from the data source cannot be converted to type float of the specified target column."
Open the component that is failing and review the metadata. You have a float column somewhere and you are passing this column a string that can't be converted to a float, such as empty space or an alphanumeric value.
If you want to ensure these values are floats, you can add a script component above the one that is failing and write some code to ensure the value is properly sanitized:
string input = "1.1"; //Replace with your input buffer value
float result;
float.TryParse(input, out result); //Result = 0.0 if value was not parsed
Please add a data conversion task between source and destination to change data type from string to float , it will resolve your issue .
If still you are facing the issue then let me know the exact issue what are the source and which ssis task you are using.
Use ole db source and destination instead of odc and try to reduce the column name length and no paranthesis in column names and use table and fast load this should solve. I had the same problem where loading from analysis services cube through dax query into SQL Table of my local machine

SSIS data conversion from CSV source column NULL to DB destination Decimal(18,2)

First of all, when the column isn't NULL, it is successfully able to do the conversion. The destination DB field accepts null values.
In my Data Conversion step I have set the Input Column's DataType to numeric[DT_Numeric], Precision 18, and Scale 2.
I have two rows in my CSV, the first row does not contain any NULLS.. and if I execute that it's a success. However when I add a 2nd row with a NULL value in that column it fails and I get these errors:
[Data Conversion [2]] Error: Data conversion failed while converting column "Column 24" (138) to column "DbColumn24" (22). The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
[Data Conversion [2]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Data Conversion.Outputs[Data Conversion Output].Columns[DbColumn24]" failed because error code 0xC020907F occurred, and the error row disposition on "Data Conversion.Outputs[Data Conversion Output].Columns[DbColumn24]" 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.
[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Data Conversion" (2) failed with error code 0xC0209029 while processing input "Data Conversion Input" (3). 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.
I do not think I need a Derived Column step before data conversion step to handle any nulls because the DB column accepts nulls.
Since your source is a CSV, I doubt that you actually have any NULL values in your source at all. More likely you have empty string values, which are not the same as NULL, and empty strings cannot be implicitly converted to Decimal. You will probably have to explicitly convert the empty strings to NULL in an expression.
The work around would be
1) First convert the column to varchar/nvarchar
2) Use derived column to convert to Decimal
3) Map the converted column to destination

SSIS Issue with date conversion

I'm working on importing a CSV into my DB. The data should work, it's data from another application that we used to get through a dblink that we now have to get from CSV thanks to an upgrade.
Dates look like this: 4/30/2001
I tried to do a simple import like I do with numbers and strings, and got an error, so I did a derived column.
The derived column works on the dates that are not null (formula is (DT_DATE)DTE)
The derived column however failed on dates that can contain nulls. I even tried to update the formula to (ISNULL(EDTE) ? NULL(DT_DATE) : (DT_DATE)EDTE). No success, I still get the error:
[Flat File Source - O1 [6743]] Error: Data conversion failed. The data conversion for column
"EDTE" returned status value 2 and status text "The value could not be converted because of a
potential loss of data.".
Originally, in my flat file source, the dates were set to type date, and I got an error before it even got to the derived column. I've changed that to String, and it makes it to derived column, but both boxes are red. Here's the error:
[Derived Column 1 [17270]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.
The "component "Derived Column 1" (17270)" failed because error code 0xC0049063 occurred,
and the error row disposition on "input column "EDTE" (17809)" 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.
Has anyone seen this? Am I importing my data in wrong?
I found the solution.
I import the date as a String. Then using derived column, I use this formula to convert it:
RTRIM([T-DTE]) == "" ? NULL(DT_DATE) : (DT_DATE)[T-DTE]

Resources