返回列表 发新帖

[sql异常]SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的

[复制链接]

29

主题

107

帖子

187

积分

注册会员

Rank: 2

积分
187
发表于 2019-6-12 11:29:13 | 显示全部楼层 | 阅读模式
  1. //执行远程数据库表查询

  2. SELECT * FROM OPENDATASOURCE('SQLOLEDB',

  3.                                'Data Source=数据库地址;User ID=sa;password=sa'

  4.                                ).northwind.dbo.title



  5. 出现异常:





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


  8. 利用沙盒模式失败时需要用到,解决方法:
  9. 启用Ad Hoc Distributed Queries:
  10. exec sp_configure 'show advanced options',1
  11. reconfigure
  12. exec sp_configure 'Ad Hoc Distributed Queries',1
  13. reconfigure



  14. 关闭Ad Hoc Distributed Queries:
  15. exec sp_configure 'Ad Hoc Distributed Queries',0
  16. reconfigure
  17. exec sp_configure 'show advanced options',0
  18. reconfigure
复制代码

  1. //执行远程数据库表查询

  2. SELECT * FROM OPENDATASOURCE('SQLOLEDB',

  3.                                'Data Source=数据库地址;User ID=sa;password=sa'

  4.                                ).northwind.dbo.title



  5. 出现异常:





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


  8. 利用沙盒模式失败时需要用到,解决方法:
  9. 启用Ad Hoc Distributed Queries:
  10. exec sp_configure 'show advanced options',1
  11. reconfigure
  12. exec sp_configure 'Ad Hoc Distributed Queries',1
  13. reconfigure



  14. 关闭Ad Hoc Distributed Queries:
  15. exec sp_configure 'Ad Hoc Distributed Queries',0
  16. reconfigure
  17. exec sp_configure 'show advanced options',0
  18. reconfigure
复制代码


回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表