2013-08-30 113 views
1

我有一个包含大约301808行和2列的excel 2007文件。我试图使用SSIS导入,但不能使用2007 excel。然后我决定尝试在SQL Server中创建一个链接服务器,按照此处的说明操作:使用SQL Server 2005导入Excel 2007文件

  • 在SQL Server Management Studio中,展开对象资源管理器中的服务器对象。
  • 右键单击链接服务器,然后单击新建链接的服务器。
  • 在左侧窗格中,选择常规页面,然后按照下列步骤操作:
  • 在第一个文本框中键入链接服务器的任何名称。
  • 选择其他数据源选项。
  • 在提供程序列表中,单击Microsoft Jet 4.0 OLE DB提供程序。
  • 在产品名称框中,键入Excel作为OLE DB数据源的名称。
  • 在数据源框中,键入Excel文件的完整路径和文件名。
  • 在提供程序字符串框中,为Excel 2002,Excel 2000或Excel 97 - 工作簿键入Excel 8.0。
  • 单击确定以创建新的链接服务器。

从这里:http://support.microsoft.com/kb/306397/EN-US

但是说明书只覆盖以前的Excel文件没有2007年那么我抬起头连接字符串为2007年和链接的服务器的设置中使用Excel的12.0,而不在Excel 8.0:

  • 提供信息:Microsoft Office 12.0 Access数据库引擎OLE DB
  • 提供产品名称:Excel数据源:C:\ Documents和
  • Setti NGS \用户名\桌面\ MAIN \ FilesIns \ MyExcelFile.xlsx提供商
  • 字符串:Excel的12.0
  • 地点:
  • 目录:

然后我得到这个错误:

The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "EXCEL_MY_FILE" does not contain the table "Report 1$". The table either does not exist or the current user does not have permissions on that table.

我进入安全并添加NT权限\系统,以防万一它是权限问题,它仍然给了我上面的错误。

excel表被称为“报告1”。

我也使用OPENROWSET在SQL来看看发生了什么试过,我得到这个:

SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server.

我又试图在下面链接的代码,看看它是否帮助了我使用OPENROWSET:

How to enable Ad Hoc Distributed Queries

EXEC sp_configure 'show advanced options', 1 
RECONFIGURE 
GO 
EXEC sp_configure 'ad hoc distributed queries', 1 
RECONFIGURE 
GO 

,并得到:

OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Syntax error in FROM clause.". Msg 7321, Level 16, State 2, Line 1 An error occurred while preparing the query "Select * from C:\Documents and Settings\UserName\Desktop\Main\FilesIns\MyExcelFile.xlsx" for execution against OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".

所以我不确定我的openrowset语句中的值是否正确。

真的只是寻找一种方式来导入这个文件到SQL表中而不使用SSIS - 我无法使用它。

感谢

安德鲁

回答

相关问题