简体   繁体   English

将Excel数据导入SQL Server 2008 R2 Express

[英]Importing Excel Data into SQL Server 2008 R2 Express

There seems to have been many discussions on this but I couldn't find something specific to what I am looking for. 似乎已经对此进行了很多讨论,但是我找不到自己想要的东西。 I am trying to use a query to import data from Excel to an existing table in SQL Server. 我正在尝试使用查询将数据从Excel导入到SQL Server中的现有表。

My query is: 我的查询是:

INSERT INTO DailyRawData
   SELECT *
   FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
                   'Excel 12.0 Xml; HDR=NO;
                   Database=C:\Users\home\Desktop\SQLImportTrim.xls', [data$]);

I get the following error: 我收到以下错误:

Msg 7314, Level 16, State 1, Line 2 Msg 7314,第16级,状态1,第2行
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" does not contain the table "data$". 链接服务器“(null)”的OLE DB提供程序“ Microsoft.ACE.OLEDB.12.0”不包含表“ data $”。 The table either does not exist or the current user does not have permissions on that table. 该表不存在,或者当前用户对该表没有权限。

I don't think this is a permission issue for me as I am set up as SysAdmn. 我认为这不是我的权限问题,因为我已设置为SysAdmn。 I am wondering if the error is due to the last part of the query [data$] since this is what the error msg refers to. 我想知道错误是否是由于查询[data$]的最后部分引起的,因为这是错误消息所指的内容。 FYI the name of the excel file is SQLImportTrim and the tab that contains all my data is named data . 仅供参考,excel文件的名称是SQLImportTrim ,包含我所有数据的选项卡名为data There is no table named data in my Excel file. 我的Excel文件中没有名为data表。 Is my query correct? 我的查询正确吗?

您不使用[data $],而是使用工作表的名称,因此,如果未重命名,则标准起始点通常是[Sheet1 $]。

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

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