`

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

 
阅读更多

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

2011-04-15 09:47:30|  分类: SQL小结 |字号 订阅

SQL Server 阻止了对组件 \'Ad Hoc Distributed Queries\' 的访问

    在Sql Server中查询一下Excel文件的时候出现问题:
SELECT *  FROM OPENROWSET( 'MICROSOFT.JET.OLEDB.4.0','Excel 8.0;IMEX=1;HDR=YES;DATABASE=D:\a.xls',[sheet1$])
    结果提示:
    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
    使用完成后,关闭Ad Hoc Distributed Queries:
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure


--查询示例
select * from openrowset('SQLOLEDB' , 'sql服务器名' ; '用户名' ; '密码' , 数据库名.dbo.表名)
分享到:
评论

相关推荐

    启用Ad Hoc Distributed Queries的方法

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

    Office数据库升迁 Access 导入 SQL Server

    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....

    SQLserver直连Excel文件取数据用例.zip

    1、SQLServer直连Excel做数据查询方法 2、Microsoft.ACE.OLEDB.12.0驱动下载 ... --漏了下面2个语句要开启参数 EXEC sp_configure 'show advanced ...EXEC sp_configure 'Ad Hoc Distributed Queries', 1 GO RECONFIGURE

    远程数据导入|更新

    --打开远程连接命令,不打开不可以执行 exec sp_configure 'show advanced options',1 reconfigure exec sp_configure 'Ad Hoc Distributed Queries',1 reconfigure

    Excel导入Sqlserver数据库脚本

    受以前旧同事之托,在博客里发这段脚本: exec sp_configure ‘show advanced options’,1 reconfigure exec sp_configure ‘Ad Hoc Distributed Queries’,1 reconfigure SELECT * INTO tmp_asset FROM OPENROWSET(...

    驾照理论考试速成软件 MFC源代码

    exec sp_configure 'Ad Hoc Distributed Queries',1 reconfigure create database jz go use jz SELECT * INTO car FROM OPENDATASOURCE ('Microsoft.Jet.OLEDB.4.0', 'Data Source="D:\GCLsoft\jz\Debug\...

    SQL直接操作excel表(查询/导入/插入)

    GO EXEC sp_configure ‘Ad Hoc Distributed Queries’, 1; GO RECONFIGURE; GO SQL SERVER 和EXCEL的数据导入导出 1、在SQL SERVER里查询Excel数据: — ====================================================== ...

    SQL高级应用之使用SQL查询Excel表格数据的方法

    代码如下: exec sp_configure ‘show advanced options’,1 reconfigure exec sp_configure ‘Ad Hoc Distributed Queries’,1 reconfigure 代码如下: SELECT * FROM OPENDATASOURCE(‘Microsoft.Jet.OLEDB.4.0’, ...

    SQL入侵恢复xp_cmdshell方法总结

    1433 SQL入侵恢复xp_cmdshell方法总结 sql server 2005下开启xp_cmdshell的办法 EXEC sp_configure ‘show advanced options’, 1;RECONFIGURE;...exec sp_configure ‘Ad Hoc Distributed Queries’,1;

    SQL 分布式查询、插入递增列示例

    — 开启高级配置 RECONFIGURE EXEC sp_configure ‘Ad Hoc Distributed Queries’, 1;–开启分布式查询 RECONFIGURE set IDENTITY_insert TestTable on –设置 某表允许插入递增量 INSERT INTO TestTable(ID,Date,...

    Handbook of Big Data Technologies

    Exploratory Ad-Hoc Analytics for Big Data 1 Exploratory Analytics for Big Data 2 A Top-K Entity Augmentation System 3 DrillBeyond -- Processing Open World SQL 4 Summary and Future Work Pattern ...

    sigmod2011全部论文(3)

    Automatic Example Queries for Ad Hoc Databases (Page 1319) Bill Howe (University of Washington) Garret Cole (University of Washington) Nodira Khoussainova (University of Washington) Leilani Battle ...

Global site tag (gtag.js) - Google Analytics