欢迎投稿

今日深度:

SQL Server 阻止了对组件 'Ad Hoc Distributed Queries

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


原因:在从远程服务器复制数据到本地时出现

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

错误,因此网上搜索,发现以下解决方法:

启用Ad Hoc Distributed Queries:

[sql] view plaincopyprint?
  1. exec sp_configure 'show advanced options',1  
  2. reconfigure  
  3. exec sp_configure 'Ad Hoc Distributed Queries',1  
  4. reconfigure  



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

[sql] view plaincopyprint?
  1. exec sp_configure 'Ad Hoc Distributed Queries',0  
  2. reconfigure  
  3. exec sp_configure 'show advanced options',0  
  4. reconfigure   

人验证成功!


怎启用与关闭 Ad Hoc Distributed Queries

今天调试公司的程序时,发现了这样的错误
SQL Server 阻止了对组件
'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource'
于是在网上搜索了一下解决办法
启用Ad Hoc Distributed Queries:execsp_configure'show advanced options',1reconfigureexecsp_configure'Ad Hoc Distributed Queries',1reconfigure
关闭Ad Hoc Distributed Queries:execsp_configure'Ad Hoc Distributed Queries',0reconfigureexecsp_configure'show advanced options',0reconfigure
就字面的意思上看,这是一个分布式查询的服务,在去MSDN上查了一下资料:
默认情况下,SQL Server 不允许使用 OPENROWSET 和 OPENDATASOURCE 进行即席分布式查询。
此选项设置为 1 时,SQL Server 允许进行即席访问。
如果此选项未设置或设置为 0,则 SQL Server 不允许进行即席访问。
即席分布式查询使用 OPENROWSET 和 OPENDATASOURCE 函数连接到使用 OLE DB 的远程数据源。
OPENROWSET 和 OPENDATASOURCE 只应在引用不常访问的 OLE DB 数据源时使用。
对于将要经常访问的数据源,应定义链接服务器。
MSDN自然也很给力的给了事例代码
下面的示例启用即席分布式查询,然后使用OPENROWSET
函数查询名为Seattle1的服务器。
sp_configure'show advanced options',1;
RECONFIGURE;sp_configure'Ad Hoc Distributed Queries',1;
RECONFIGURE;GOSELECTa.*FROMOPENROWSET('SQLNCLI','Server=Seattle1;Trusted_Connection=yes;','SELECT GroupName, Name, DepartmentID
FROM AdventureWorks2012.HumanResources.Department
ORDER BY GroupName, Name')ASa;GO
允许使用临时名称意味着到 SQL Server 的任何经过身份验证的登录名均可访问该访问接口。
SQL Server 管理员应对任何本地登录名都能安全访问的访问接口启用此功能。
 

SQL Server怎启用Ad Hoc Distributed Queries?

1、启用Ad Hoc Distributed Queries的办法SQL Server 阻拦了对组件""Ad Hoc Distributed Queries"" 的STATEMENT""OpenRowset/OpenDatasource""的接见,因为此组件已作为此办事器安然设备的一项目组而被封闭。体系经管员可以经由过程应用。

reconfigure;应用完毕后,记得必然要封闭它,因为这是一个安然隐患,切记履行下面的SQL语句:exec sp_configure 'Ad Hoc Distributed Queries',0 reconfigure exec sp_configure 'show advanced options',0 reconfigure 2、应用示例创建链接办事器 exec s p_addlinkedserver ""ITSV "", "" "", ""SQLOLEDB "", ""长途办事器名或ip地址 "" exec s p_addlinkedsrvlogin ""ITSV "", ""false "",null, ""用户名 "", ""暗码 "" 查询示例 * ITSV.数据库名.dbo.表名 导入示例 * into 表 ITSV.数据库名.dbo.表名 今后不再应用时删除链接办事器 exec s p_dropserver ""ITSV "", ""droplogins "" 3、连接长途/局域网数据(openrowset/openquery/opendatasource) 1、openrowset 查询示例 * openrowset( ""SQLOLEDB "", ""sql办事器名 ""; ""用户名 ""; ""暗码 "",数据库名.dbo.表名) 生成本地表 * into 表 openrowset( ""SQLOLEDB "", ""sql办事器名 ""; ""用户名 ""; ""暗码 "",数据库名.dbo.表名) 把本地表导入长途表 openrowset( ""SQLOLEDB "", ""sql办事器名 ""; ""用户名 ""; ""暗码 "",数据库名.dbo.表名) * 本地表 更新本地表 b set b.列A=a.列A openrowset( ""SQLOLEDB &qu......余下全文>>
 

www.htsjk.Com true http://www.htsjk.com/shujukunews/2085.html NewsArticle SQL Server 阻止了对组件 Ad Hoc Distributed Queries 的 STATEMENTOpenRowset/OpenDatasource 的访问,openrowset 原因:在从远程服务器复制数据到本地时出现 “SQL Server 阻止了对组件 'Ad Hoc Distributed Queries...
评论暂时关闭