Data import from Excel to SQL Server failing to import all data

前端 未结 11 1687
一向
一向 2021-02-04 07:26

I have an odd thing happening with importing data from Excel to SQL Server using the Import and Export Data tool.

The short of it is that I can see the data in Excel, bu

相关标签:
11条回答
  • 2021-02-04 08:14

    Most probably that supposedly blank row causing Sql Server to ignore the rest of the data. Bu to be sure could you share the schema of the excel file and the first five rows? The correct three and the next two records.

    0 讨论(0)
  • 2021-02-04 08:17

    My issue was that the file that I was importing was an older and somewhat maligned excel file. I opened up the file and saved it as a .xlsx and the file imported successfully with no null data after that.

    0 讨论(0)
  • 2021-02-04 08:18

    The answer to your question might involve the HOW data is stored in Excel.

    I just ran into the same problem. I had a column containing two types of values: numeric and numeric with a dash. (ex. 51000 and 2009-00949) I needed to import them as either NVARCHAR or VARCHAR, but the SQL import wizard (SQL2005) would only import the numerics and not the numerics with a dash or the numerics with a dash and not the numerics, depending on which type was in the first record. The values which were not imported would have a 'null' value in the field, rendering my records useless.

    I tried using the Format|Cells menu option in Excel (numeric, text, general, etc) and various mapping options in SQL (nvar, nvarchar, varchar, sqlvariant, float) without success.

    The solution was to use the Data|Text To Columns option in Excel, not the cell formatting option to store the numeric value as text. When I used this on the column, the numeric values (ex. 51000) converted to numbers stored as a text value (little green triangle error appeared in the upper left corner), the numerics with a dash remained as text. I had to leave the data in this format, with the little green triangle error, otherwise it would not successfully import to SQL. When the data in the column was stored in this format, the two types of column data (numeric and numeric with a dash) imported correctly with the other record data, no null values in the column.

    0 讨论(0)
  • 2021-02-04 08:21

    it seems that the import tool from SSMS takes a sample of the first 'x' rows to decide the data type of the column and other characteristics of it, so if it chooses is double it will take the text values as null and if it reads it as text no number will show. If you have Microsoft Access you can first use the access import which allows you to choose your own column types and save it as an access file, then import the access to SQL server and 'voila', it works (at least for me), I hope it helps someone.

    0 讨论(0)
  • 2021-02-04 08:25

    I was uploading data to an existing table. What I did was script out the existing table to validate that the columns I was importing matched the existing columns. Turns out one of my columns wasn't matching and it was only partially importing the data set.

    0 讨论(0)
提交回复
热议问题