SSIS Excel Import Forcing Incorrect Column Type

后端 未结 16 1163
醉梦人生
醉梦人生 2020-11-30 01:06

I\'m trying to import a spreadsheet to our database using SSIS. For some reason SSIS wants to believe two of the columns are of type Double, when they contain character dat

相关标签:
16条回答
  • 2020-11-30 01:27

    You can convert (ie. force) the column data to text... Try this (Note: These instructions are based on Excel 2007)...

    The following steps should force Excel to treat the column as text:

    Open your spreadsheet with Excel.

    Select the whole column that contains your "mostly numeric data" by clicking on the column header.

    Click on the Data tab on the ribbon menu.

    Select Text to Columns. This will bring up the Convert Text to Columns Wizard.

    -On Step 1: Click Next

    -On Step 2: Click Next

    -On Step 3: Select Text and click Finish

    Save your Excel sheet.

    Retry the import using the SQL Server 2005 Import Data Wizard.

    Also, here's a link to another question which has additional responses:

    Import Data Wizard Does Not Like Data Type I Choose For A Column

    0 讨论(0)
  • 2020-11-30 01:27
    1. Click File on the ribbon menu, and then click on Options.
    2. Click Advanced, and then under When calculating this workbook, select the Set precision as displayed check box, and then click OK.

    3. Click OK.

    4. In the worksheet, select the cells that you want to format.

    5. On the Home tab, click the Dialog Box Launcher Button image next to Number.

    6. In the Category box, click Number.

    7. In the Decimal places box, enter the number of decimal places that you want to display.

    0 讨论(0)
  • 2020-11-30 01:30

    It took me a bit to realize the source of the error in my package. Ultimately I found that data was converted to null (Example: from "06" to "NULL"), and I found this via Preview in the source file connection (Excel Source> Edit> Connection Manager> Sheet='MySheet'> Preview...). I got excited when I read the post by James to edit the connection string to have extended properties: ;Extended Properties="IMEX=1". But that did not work for me.

    I was able to resolve the error by changing the Cell Format in Excel worksheet from “Number” to “Text”. After changing the format, the upload process ran successfully! My connection string looks like: Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\myServer\d$\Folder1\Folder2\myFile.xlsx;Extended Properties="EXCEL 12.0 XML;HDR=NO";

    Here is are some screenshots that resolved my error message.

    Error: Metadata of Excel file connection

    Source of error: “General” format

    Source of error changed: “Text” format

    Error fixed: Metadata of Excel file connection

    0 讨论(0)
  • 2020-11-30 01:32

    I had the same issue, multiple data type values in single column, package load only numeric values. Remains all it updated as null.

    Solution

    To fix this changing the excel data type is one of the solution. In Excel Copy the column data and paste in different file. Delete that column and insert new column as Text datatype and paste that copied data in new column.

    Now in ssis package delete and recreate the Excel source and destination table change the column data type as varchar.

    This will work.

    0 讨论(0)
  • 2020-11-30 01:33

    Option 1. Use Visual Basic to iterate through each column and format each column as Text.

    Use the Text-to-Columns menu, don't change the delimination, and change "General" to "Text"

    0 讨论(0)
  • 2020-11-30 01:37

    I've seen this issue before, it's Excel that is the issue not SSIS. Excel samples the 1st few rows and then infers the data type even if you explicitly set it to text. What you need to do is put this into the Excel file connection string in the SSIS package. This instruction tells Excel that the columns contain mixed data types and hints it to do extra checking before deciding that the column is a numeric type when in fact it's not.

    ;Extended Properties="IMEX=1"
    

    It should work with this (in most cases). The safer thing to do is export the Excel data to tab delimited text and use SSIS to import that.

    • http://blogs.acceleration.net/ryan/archive/2005/01/11/477.aspx
    0 讨论(0)
提交回复
热议问题