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

岁酱吖の 提交于 2019-12-04 10:40:53

问题


Does anybody else have this same problem, when you import data from Excel file to MSSQL Server 2005, if some column contains mostly numeric data, but even if you set the column type to varchar, the wizard fails to import those fields that fail to parse as numbers?


回答1:


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.




回答2:


You need to edit the connection string that SSIS uses. Add this to the end of the string "IMEX=1;" (No quotes) That tells SSIS/jet to not try and figure out what the data types are. Just import them.




回答3:


You might try tweaking Jet settings for importing Excel data. You can force the Jet engine to sample the entire sheet when trying to determine the column type during a given import. Change the following registry key (after making a backup first) and see if that doesn't do it:

HKLM\Software\Microsoft\Jet\4.0\Engines\Excel

Or on x64

HKLM\Software\Wow6432Node\Microsoft\Jet\4.0\Engines\Excel

Set the value TypeGuessRows equal to zero. This will force Jet to sample all rows to determine the column type.




回答4:


Create a new column that is an apostophe + the contents of the column you want to import. This will force it to be a string

="'"&E2




回答5:


Adding IMEX=1 BEFORE the HDR setting worked for me.




回答6:


This is the best solution:

  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.



来源:https://stackoverflow.com/questions/779754/import-data-wizard-does-not-like-data-type-i-choose-for-a-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!