Failing to read String value from an excel column

前端 未结 1 855
悲哀的现实
悲哀的现实 2021-01-20 12:52

SSIS script task reading only numeric values of excel but fails to read the alphanumeric values present in the same column

I\'ve tried using IMEX=0, IMEX=1 and IMEX=

相关标签:
1条回答
  • 2021-01-20 13:21

    This issue is related to the OLEDB provider used to read excel files: Since excel is not a database where each column has a specific data type, OLEDB provider tries to identify the dominant data types found in each column and replace all other data types that cannot be parsed with NULLs.

    There are many articles found online discussing this issue and giving several workarounds (links listed below).

    But after using SSIS for years, I can say that best practice is to convert excel files to csv files and read them using Flat File components.

    Or, if you don't have the choice to convert excel to flat files then you can force excel connection manager to ignore headers from the first row bu adding HDR=NO to the connection string and adding IMEX=1 to tell the OLEDB provider to specify data types from the first row (which is the header - all string most of the time), in this case all columns are imported as string and no values are replaced with NULLs but you will lose the headers and a additional row (header row is imported).

    If you cannot ignore the header row, just add a dummy row that contains dummy string values (example: aaa) after the header row and add IMEX=1 to the connection string.

    SchemaMapper Excel Import class

    In addition, it is good to check the following class which is a part of SchemaMapper project, I implemented the logic mentioned above in order to fix this problem:

    • SchemaMapper - MsExcelImport.cs

    Helpful links

    • SSIS Excel Data Import - Mixed data type in Rows
    • Mixed data types in Excel column
    • Importing data from Excel having Mixed Data Types in a column (SSIS)
    • Why SSIS always gets Excel data types wrong, and how to fix it!
    • EXCEL IN SSIS: FIXING THE WRONG DATA TYPES
    • IMEX= 1 extended properties in ssis
    0 讨论(0)
提交回复
热议问题