[英]Importing Excel 2007 File Using SQL Server 2005
I have an excel 2007 file with about 301808 rows and 2 columns. 我有一个具有301808行和2列的Excel 2007文件。 I was trying to use SSIS to import but cant use 2007 excel. 我试图使用SSIS导入,但是不能使用2007 excel。 I then decided to try and make a linked server in SQL Server, Following the instructions here: 然后,我决定按照此处的说明尝试在SQL Server中制作链接服务器:
From Here: http://support.microsoft.com/kb/306397/EN-US 从这里: http : //support.microsoft.com/kb/306397/EN-US
However the instructions only covers previous excel files not 2007 so I looked up connection strings for 2007 and used Excel 12.0 instead of Excel 8.0 in settings of linked server: 但是,这些说明仅涵盖了以前的excel文件,而没有涵盖2007年,因此我查找了2007年的连接字符串,并在链接服务器的设置中使用了Excel 12.0而不是Excel 8.0:
I then got this error: 然后我得到了这个错误:
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "EXCEL_MY_FILE" does not contain the table "Report 1$". 链接服务器“ EXCEL_MY_FILE”的OLE DB提供程序“ Microsoft.ACE.OLEDB.12.0”不包含表“ Report 1 $”。 The table either does not exist or the current user does not have permissions on that table. 该表不存在,或者当前用户对该表没有权限。
I went into security and added nt authority\\system just in case it was permissions problem and it still gave me the error above. 我进入安全性并添加了nt权限\\系统,以防万一这是权限问题,但仍然给我上面的错误。
The excel table is called 'Report 1'. excel表称为“报表1”。
I also tried using openrowset in sql to see what happened and I got this: 我也尝试在sql中使用openrowset看看发生了什么,我得到了:
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. SQL Server阻止访问组件“ Ad Hoc Distributed Queries”的状态“ OpenRowset / OpenDatasource”,因为此组件的安全配置已关闭此组件。
I then tried the code in link below to see if it helped me use openrowset: 然后,我尝试了下面链接中的代码,以查看它是否有助于我使用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
And got: 并得到:
OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Syntax error in FROM clause.". 链接服务器“(null)”的OLE DB提供程序“ Microsoft.ACE.OLEDB.12.0”返回了消息“ FROM子句中的语法错误”。 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)". 消息7321,级别16,状态2,行1为针对OLE DB提供程序“ Microsoft”执行的查询“从C:\\ Documents and Settings \\ UserName \\ Desktop \\ Main \\ FilesIns \\ MyExcelFile.xlsx中选择*”而准备查询时发生错误。链接服务器“(null)”的“ ACE.OLEDB.12.0”。
So I am not sure if the values in my openrowset statement are correct. 因此,我不确定openrowset语句中的值是否正确。
Really just looking for a way to import this file into an sql table without using SSIS - I cant use it anyway. 真的只是在寻找一种无需使用SSIS即可将此文件导入sql表的方法-无论如何我都无法使用它。
Thanks 谢谢
Andrew 安德鲁
Under your sp_Reconfigure, see that you reference an article here.. However, I think you may need to go to Microsoft instead.. 在您的sp_Reconfigure下,请参见此处引用的文章。但是,我认为您可能需要去Microsoft。
http://technet.microsoft.com/en-us/library/ms187569%28v=sql.90%29.aspx http://technet.microsoft.com/zh-cn/library/ms187569%28v=sql.90%29.aspx
And there are quite a few examples of how to use OPENROWSET here - 这里有很多有关如何使用OPENROWSET的示例-
http://technet.microsoft.com/en-us/library/ms190312%28v=sql.90%29.aspx http://technet.microsoft.com/zh-cn/library/ms190312%28v=sql.90%29.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.