简体   繁体   English

从MS Excel导入数据到SQL Server 2008 R2

[英]Importing data from MS Excel to SQL Server 2008 R2

I've a Microsoft Excel file with 25 columns and I used the data import wizard on SQL Server 2008 R2 studio to import it to already existing table. 我有一个25列的Microsoft Excel文件,并且使用SQL Server 2008 R2 studio上的数据导入向导将其导入到现有表中。 But, it only maps 14 columns and ignores the rest. 但是,它仅映射14列,而忽略其余的列。 Does it have a column number limit or there is a problem with my data? 是否有列数限制或我的数据有问题?

Can you give some example of your data? 您能否举一些数据示例?

In the mean time... When you're performing your import, I assume you are reaching the Select Source Tables and Views Page; 同时,当您执行导入时,我假设您正在进入“ Select Source Tables and Views页面;

在此处输入图片说明

At this stage, you can edit your column mappings by pressing the Edit Mappings button. 在此阶段,您可以通过按“ Edit Mappings按钮来编辑列映射。 This will show the following screen; 这将显示以下屏幕;

在此处输入图片说明

Make sure that all your columns are selected there. 确保在那里选择了所有列。

Also, on the following screen, it will warn of any mismatches in data; 另外,在以下屏幕上,它将警告任何数据不匹配的情况;

在此处输入图片说明

Are you seeing any warnings here? 您在这里看到任何警告吗?

I'm not familiar much with SQL Server, but according to this: Excel file Import to Sql server 2008 - column limit for Excel is 255 which is far beyond your numbers. 我对SQL Server不太熟悉,但是据此: Excel文件导入到Sql Server 2008中-Excel的列限制为255 ,这远远超出了您的数字。 Most likely problem is in your data, but without having the example it's impossible to say what's wrong. 最有可能的问题出在您的数据中,但是如果没有示例,就不可能说出问题所在。

You can do the other way around. 您可以采取其他方法。

Step 1. Import sheet in a new table. 步骤1. 将工作表导入新表中。

Step 2. Use Bulk Query to insert into your prefered table 第2步。 使用批量查询插入到您的首选表

I think this will solve your Problem . 我认为这将解决您的问题

Try to create the Excel columns and table structure in the same format and structure as ms sql table is. 尝试以与ms sql table相同的格式和结构创建Excel列和表结构。 Open the excel select the row (whole row by clicking on row number) select the whole data till end of the data (selected first row to last row). 打开excel,选择行(单击行号可整行),选择整个数据,直到数据结束为止(选择第一行到最后一行)。 press ctrl+c 按Ctrl + C

edit the ms sql table, go to last row where you can find blank. 编辑ms sql表,转到最后一行,您可以在其中找到空白。

Select that row by clicking on row button and press ctrl+v. 通过单击行按钮选择该行,然后按ctrl + v。

Done you're excel data will be inserted into sql table. 完成后,您将Excel数据插入到sql表中。

I tried it in MS SQL 2008 我在MS SQL 2008中尝试过

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM