SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 的访问

1、错误信息 

SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用 'Ad Hoc Distributed Queries'。有关启用 'Ad Hoc Distributed Queries' 的详细信息,请参阅 SQL Server 联机丛书中的 "外围应用配置器"。

2、错误出处

执行语句:select *  FROM OpenDataSource ('Microsoft.Jet.OLEDB.4.0','Data Source="c:\\2012.xls"; User ID=;Password=; Extended properties=Excel 5.0')...[Sheet$] (只需要执行上面语句,就可以把excel数据导入数据库)

或者

进行两台Sql Server服务器之间同步数据

3、解决办法

     a、启用Ad Hoc Distributed Queries:

      exec sp_configure 'show advanced options',1
      reconfigure
      exec sp_configure 'Ad Hoc Distributed Queries',1
      reconfigure

 

     b、使用完成后,关闭Ad Hoc Distributed Queries:

      exec sp_configure 'Ad Hoc Distributed Queries',0
      reconfigure
      exec sp_configure 'show advanced options',0
      reconfigure 

 

 

posted @ 2016-03-22 13:43  有时  阅读(273)  评论(0编辑  收藏  举报