时间:2021-07-01 10:21:17 帮助过:29人阅读
1. 机器环境 win7家庭版32位操作系统sqlserver2008 32位英文版 2.测试操作 SELECT a.* FROM openrowset('MICROSOFT.JET.OLEDB.4.0','Excel 8.0;HDR=YES;DATABASE=e:\Book1.xls','select * from [sheet1$]') as a 3.报错 SQL Server blocked access to STATEM
1. 机器环境
win7家庭版32位操作系统+sqlserver2008 32位英文版
2.测试操作
SELECT a.*
FROM openrowset('MICROSOFT.JET.OLEDB.4.0','Excel 8.0;HDR=YES;DATABASE=e:\Book1.xls','select * from [sheet1$]') as a
3.报错
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. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online.
查了别人的解决方案:
执行如下语句:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
SELECT a.*
FROM openrowset('MICROSOFT.JET.OLEDB.4.0','Excel 8.0;HDR=YES;DATABASE=e:\Book1.xls','select * from [sheet1$]') as a
问题解决
4.有位同行按照上面的说法,报了如下错误:
OLE DB 访问接口 'Microsoft.Jet.OLEDB.4.0' 配置为在单线程单元模式下运行,所以该访问接口无法用于分布式查询
问了他的配置:win7 旗舰版64位+slqserver2008 英文的64位,office2010 32位
解决办法:
(注意中英文版本)
http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/58c4c61e-fa86-4809-bf7d-21bacb055d3e/
下载最新的驱动
原因是:在64SQL Engine中已经不提供jet.oledb.4.0的驱动了
解决方法:下载一个ACE.Oledb.12.0 for X64位的驱动,并把连接字符串Microsoft.jet.Oledb.4.0 更改为 Microsoft.ACE.OLEDB.12.0
安装的时候:提示:
乖乖的卸载32为的office产品吧,谁让你们技术这么前卫的呢
看了有位朋友总结的有关将不同版本的excel导入到sqlserver的文章,比较全面
连接如下:
http://hi.baidu.com/luck001221/item/74da5b3e8232aec4392ffad4