SSIS Data Import from CSV to SQL Table Failing [closed]

Posted on

Question :

I have been trying to import the data from CSV file to SQL Table. I have 7 columns which are:

  1. Refresh Date – Db_Date
  2. Report Date – DB_Date
  3. Report Period – Four byte singled Int
  4. Participated – Four byte singled Int
  5. Organized – Four byte singled Int
  6. Peert-To-Peer – Four byte singled Int

I am using Flat File Source –> Data Conversion (to convert the data in my csv to match the data type according to the above table) –> OLE DB Destination.

I am getting following errors:

  1. [Data Conversion [2]] Error: Data conversion failed while converting column “”???Report Refresh Date”” (37) to column “Copy of “???Report Refresh Date”” (11). The conversion returned status value 2 and status text “The value could not be converted because of a potential loss of data.”.

  2. [Data Conversion [2]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The “Data Conversion.Outputs[Data Conversion Output].Columns[Copy of “???Report Refresh Date”]” failed because error code 0xC020907F occurred, and the error row disposition on “Data Conversion.Outputs[Data Conversion Output].Columns[Copy of “???Report Refresh Date”]” 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.

  3. [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 am also attaching the screenshot of how my CSV file looks like. enter image description here

Any help will be helpful as I have a ton of data which needs to be load to SQL tables from CSV files.

Answer :

The key here is a short snippet from the first error message:
Data conversion failed while converting column ""???Report Refresh Date"" (37) to column "Copy of "???Report Refresh Date"" (11).

This sort of error is always a pain to track down, but in short, it’s saying that for some reason it’s encountering a value that it’s unable to convert to a date.

One trick you can use to try and figure out where the problem is located is to look at the number of rows the package is able to process before erroring out. You can usually see this by entering into the data flow task in question. If it’s able to process 15 rows before erroring, you know that the problem row is somewhere around row 16. From there, you can see if anything is in a weird format, or if any values are out-of-bounds (think 2/30/2020).

The first thing is we have not too much info related to your destination table mapping.

  1. A good practice is to remove these interrogation signs on your column’s name.
  2. Check on your plain text connection if you had specified that your file has headers in the first row.
  3. Looks like your error is raising up for a Null value conversion or a
    data type mismatch conversion.

Because is you see in the initial error means your load process is sending more characters than expected to receive, your process is sending a (37) characters, and you are expecting to receive (11) characters and this is producing a possible truncation or loss of data.

Use the advance editor on your components especially on the data conversion task and validate the Input and outputs columns then you can check if your source and destination conversions are matching.

You can follow this link to check using the advance editor.
https://www.sqlshack.com/ssis-data-types-change-from-the-advanced-editor-vs-data-conversion-transformations/

The problem was with the double quotations in the csv file. I was not declaring the text qualifier as ‘”‘. The issue has now been resolved.

Leave a Reply

Your email address will not be published. Required fields are marked *