日期:2014-05-17  浏览次数:20640 次

SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的问题
在做一个存储过程。。。在数据库测试的时候抛出如下错误。。
select * from openrowset('sqloledb','ip';'**';'**','exec test.dbo.pc_test')

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


然后上网查找解决办。。。  开启'Ad Hoc Distributed Queries' 的时候
exec sp_configure 'show advanced options',1  
reconfigure  
exec sp_configure 'Ad Hoc Distributed Queries',1  
reconfigure 
又抛出错误。。。。

配置选项 'show advanced options' 已从 0 更改为 1。请运行 RECONFIGURE 语句进行安装。
消息 5808,级别 16,状态 1,第 2 行
不支持对系统目录进行即席更新。

然后又查了下资料。。。发现2008不能对系统目录进行更新。。。
求解决办法

------解决方案--------------------
不会不支持啊
sp_configure 'show advanced options', 1;
  RECONFIGURE;
  GO
  sp_configure 'Ad Hoc Distributed Queries', 1;
  RECONFIGURE;
  GO
  /*
  Configuration option 'show advanced options' changed from 1 to 1. Run the RECONFIGURE statement to install.
Configuration option 'Ad Hoc Distributed Queries' changed from 0 to 1. Run the RECONFIGURE statement to install.

  */
  SELECT @@version
  /*
  Microsoft SQL Server 2012 (SP1) - 11.0.3128.0 (X64) 
Dec 28 2012 20:23:12 
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: )

  */

------解决方案--------------------
我用08R2的一样可以
sp_configure 'show advanced options', 1;
  RECONFIGURE;
  GO
  sp_configure 'Ad Hoc Distributed Queries', 1;
  RECONFIGURE;
  GO
  /*
Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE&