今天遇到了一个关于LINKED SERVER查询报错的案例,链接服务器链接ORACLE数据库,测试没有错误,但是执行脚本的时候,报如下错误:

Msg 7399, Level 16, State 1, Line 1

The OLE DB provider "OraOLEDB.Oracle" for linked server "xxxx" reported an error. Access denied.

Msg 7301, Level 16, State 2, Line 1

Cannot obtain the required interface ("IID_IDBCreateCommand") from OLE DB provider "OraOLEDB.Oracle" for linked server "xxxx".

其实以前遇到过类似的案例,但是这次案例发生在SQL Server 2012 (SP4) (KB4018073) - 11.0.7001.0 (X64)下,LINKED SERVER使用 Oracle Provider for OLE DB驱动,跟之前遇到的案例Cannot create an instance of OLE DB provider "OraOLEDB.Oracle" for linked server "xxxxxxx".有一些区别。解决方案相同,需要在Oracle Provider for OLE DB驱动的选项里面勾选“Allow inporcess",或者修改注册表,具体参考下面Metalink官方文档。(另外,今天还遇到了很奇葩的事情,设置后,SQL 语句在其他数据库执行OK,但是在master库下面就一直报这个错误,但是一段时间后又OK了。十分奇怪,暂时不清楚具体原因)

Metalink上Using Oracle OLE DB Provider and MS SQL Server To Acccess Oracle Database Raise Errors 7399 And 7301 (文档 ID 396648.1)的详细介绍

SYMPTOMS

You are unable to connect to the Oracle database when using Microsoft SQL Server's Linked Server and the Oracle Provider for OLE DB and receive errors messages like

Msg 7399, Level 16, State 1, Line 1

The OLE DB provider "OraOLEDB.Oracle" for linked server "TEST" reported an error. The provider reported an unexpected catastrophic failure.

Msg 7301, Level 16, State 2, Line 1

Cannot obtain the required interface ("IID_IDBCreateCommand") from OLE DB provider "OraOLEDB.Oracle" for linked server "TEST".

 

CAUSE

The Oracle Provider for OLE DB has been configured to run out-of-process (in a separate process than the SQL Server process, typically DLLHOST.EXE) but it is mandatory to run the Oracle Provider for OLE DB as in-process to function properly with SQL Server.

 

SOLUTION

Please apply solution from

Note:333327.1 Error "Could not execute query against OLE DB provider 'OraOLEDB.Oracle'" when Querying Against an Oracle Database using Microsoft SQL Server Linked Server and the Oracle Provider for OLE DB

which describes the same problem but with different symptoms.

 

REFERENCES

NOTE:333327.1 - Error "Could not execute query against OLE DB provider 'OraOLEDB.Oracle'" when Querying Against an Oracle Database using Microsoft SQL Server Linked Server and the Oracle Provider for OLE DB

另外,关于文档333327.1 ——Error "Could not execute query against OLE DB provider 'OraOLEDB.Oracle'" when Querying Against an Oracle Database using Microsoft SQL Server Linked Server and the Oracle Provider for OLE DB (文档 ID 333327.1)的具体内容如下:

APPLIES TO:

Oracle Provider for OLE DB - Version 10.2.0.1 and later
Microsoft Windows (32-bit)

***Checked for relevance on 10-Oct-2016*** 

SYMPTOMS

You are unable to connect to the Oracle database when using Microsoft SQL Server's Linked Server and the Oracle Provider for OLE DB. When issuing the following query from Microsoft's SQL Query Analyzer

SELECT * FROM DEV..SCOTT.EMP

You receive the following error

Server: Msg 7320, Level 16, State 2, Line 1
Could not execute query against OLE DB provider 'OraOLEDB.Oracle'.
OLE DB error trace [OLE/DB Provider 'OraOLEDB.Oracle' ICommandText::Execute returned 0x80040155].

If you change the query so that it will not return any rows it runs successfully

SELECT * FROM DEV..SCOTT.EMP where 1=0

CAUSE

The Oracle Provider for OLE DB has been configured to run out-of-process (in a separate process than the SQL Server process, typically DLLHOST.EXE).  The Oracle Provider for OLE DB must run in-process to function properly with SQL Server.

By SQL*Net tracing the failing query you can look at the TNS information inside of a SQL*Net trace you can see the difference between a provider running IN and OUT of process:

  In-Process Trace:

(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=gbednars-pc)(PORT=1521)))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl.rmmslang.us.oracle.com)
(CID=(PROGRAM=C:\PROGRA~1\MI6841~1\MSSQL\binn\sqlservr.exe)(HOST=GBEDNARS-PC)
(USER=SYSTEM))))

Out-Of-Process Trace:

(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=gbednars-pc)(PORT=1521)))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl.rmmslang.us.oracle.com)
(CID=(PROGRAM=C:\WINDOWS\System32\DllHost.exe)(HOST=GBEDNARS-PC)(USER=SYSTEM))))

In the In-Process trace the TNS information shows us that the Oracle Provider for OLE DB is running under the sqlservr.exe process.  In the Out-Of-Processtrace we see that the same provider is running under the DllHost.exe process.  DllHost is used as a surrogate process in place of SQL Server to host out-of-process executions and clearly shows us that the Oracle OLE DB provider has been configured this way.

SOLUTION

  1. Open the registry and check the value of the AllowInProcess key being used by the Oracle Provider for OLE DB

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Providers\OraOLEDB.Oracle
    
         AllowInProcess     REG_DWORD     0x00000000 (0)
  2. If the AllowInProcess key has been set to a value of 0 then it is configured to run out-of-process.  Change the value from 0 to 1 or if the key does not exist, create it as a DWORD with a value of 1.  The value 1 is also the default setting signifying in-process.
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Providers\OraOLEDB.Oracle
    
         AllowInProcess     REG_DWORD     0x00000001 (1)
    
    OR
    
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\Providers\OraOLEDB.Oracle
    AllowInProcess     REG_DWORD     0x00000001 (1)

NOTE:  Microsoft states that the out-of-process setting AllowInProcess=0, is not to be used with any provider other than SQLOLEDB (Microsoft's OLEDB Provider for SQL Server).  See the following link for more information:

Microsoft Knowledge Base Article ID 833388
       You cannot create out-of-process providers with MDAC OLE DB components

Additionally, the Oracle Provider for OLE DB Developer's Guide states that the Oracle Provider for OLE DB (OraOLEDB) is an in-process server.

参考资料

Using Oracle OLE DB Provider and MS SQL Server To Acccess Oracle Database Raise Errors 7399 And 7301 (文档 ID 396648.1)

Error "Could not execute query against OLE DB provider 'OraOLEDB.Oracle'" when Querying Against an Oracle Database using Microsoft SQL Server Linked Server and the Oracle Provider for OLE DB (文档 ID 333327.1)

Cannot obtain the required interface ("IID_IDBCreateCommand") from OLE DB provider "OraOLEDB.Oracle" for linked server xxxx的更多相关文章

  1. Cannot create an instance of OLE DB provider "OraOLEDB.Oracle" for linked server "xxxxxxx".

    在SQL SERVER 2008 R2下用Windows 身份认证的登录名创建了一个访问ORACLE数据库的链接服务器xxxxx,测试成功,木有问题,但是其它登录名使用该链接服务器时,报如下错误: 消 ...

  2. Cannot create an instance of OLE DB provider “OraOLEDB.Oracle” for linked server "xxxxxxx".

    在SQL SERVER 2008 R2下用Windows 身份认证的登录名创建了一个访问ORACLE数据库的链接服务器xxxxx,测试成功,木有问题,但是其它登录名使用该链接服务器时,报如下错误: 消 ...

  3. sql server2008 搭建链接服务器成功后查询时报Cannot obtain the schema rowset "DBSCHEMA_TABLES_INFO" for OLE DB provider "SQLNCLI10" for linked server "XXXXX". 的解决方法

    这是由于链接的数据库服务器的版本与本地数据库服务器不一致,有人说要升到sp3,sp4,然后在执行什么语句之类的 我觉得太繁琐了,通过网上查询之后看到可以这么做: USE master GRANT EX ...

  4. Microsoft OLE DB Provider for Oracle 在哪个安装包中

    http://www.oracle.com/technetwork/database/windows/downloads/utilsoft-098155.html oracle odbc downlo ...

  5. The operation could not be performed because the OLE DB provider 'SQLOLEDB' was unable to begin a distributed transaction

    今天遇到一起关于分布式事务错误的案例,如下所示,执行SQL脚本时报错, 错误信息具体如下所示: [OLE/DB provider returned message: 新事务不能登记到指定的事务处理器中 ...

  6. MS SQL 错误:The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "test" was unable to begin a distributed transaction.

       一同事在测试服务器(系统:Windows 2008 R2 Standard 数据库:SQL SERVER 2008 R2)通过链接服务器test使用分布式事务测试时出错,出错信息如下: set ...

  7. Microsoft OLE DB Provider for SQL Server 错误 '80040e21'

    我的是因为数据库满了,正在向服务商申请增加数据库容量 原文地址:Microsoft OLE DB Provider for SQL Server 错误 '800作者:欧阳IT记事本 昨天打开网站还正常 ...

  8. The operation could not be performed because OLE DB provider "SQLNCLI11" for linked server "SDSSDFCC...

    The operation could not be performed because OLE DB provider "SQLNCLI11" for linked server ...

  9. [转]ssis cannot retrieve the column code page info from the ole db provider

    本文转自:http://social.msdn.microsoft.com/Forums/sqlserver/en-US/dc1a61f2-1ab8-4ed3-b85c-db6481800b50/er ...

随机推荐

  1. [ Talk is Cheap Show me the CODE ] : jQuery Mobile页面布局

    当我们专注地研究人类生活的空虚,并考虑荣华富贵空幻无常时,也许我们正在阿谀逢迎自己懒惰的天性. Written In The Font 为了app的手机端,我选择了 jQuery Mobile  ,学 ...

  2. git 下载部分目录

    需求 github上整个工厂比较大,下起来费劲,如何只下载一个单独的文件件呢? 方法一 以:https://github.com/eugenp/tutorials为例,下载其中的 spring-kaf ...

  3. Apache-httpd.conf详解

    ## Apache服务器主配置文件.  包括服务器指令的目录设置.# 详见 <URL:http://www.apache.org/docs/> ## 请在理解用途的基础上阅读各指令.## ...

  4. 痞子衡嵌入式:蓝牙芯片厂商三强(Qualcomm&CSR, TI, Nordic)产品一览

    大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是蓝牙芯片三强厂商的芯片. IoT物联网是未来的趋势,半导体厂商作为IoT产业的上游,主要提供核心的无线芯片,蓝牙是比较主流的协议,下面痞 ...

  5. python模块导入细节

    python模块导入细节 官方手册:https://docs.python.org/3/tutorial/modules.html 可执行文件和模块 python源代码文件按照功能可以分为两种类型: ...

  6. go基础系列:数组

    了解Python.Perl.JavaScript的人想必都知道它们的数组是动态的,可以随需求自动增大数组长度.但Go中的数组是固定长度的,数组一经声明,就无法扩大.缩减数组的长度.但Go中也有类似的动 ...

  7. Go基础系列:简单数据类型

    每一个变量都有数据类型,Go中的数据类型有: 简单数据类型:int.float.complex.bool和string 数据结构或组合(composite):struct.array.slice.ma ...

  8. 使用meterpreter让没有安装python解释器的肉鸡设备执行任意python程序

    目标设备不需安装python解释器就能让其执行python程序 # 需要在与目标meterpreter的session中加载python模块 meterpreter > load python ...

  9. maven创建一个简单的web项目

    1.确认maven插件和配置在eclipse中已经完成 如果没完成,可参考这篇博客:http://www.cnblogs.com/mmzs/p/8191979.html 2.在eclipse中用mav ...

  10. 【golang-GUI开发】QSS的使用(一)———QSS入门指南

    在这篇文章中我们将初步体验对qss的使用.并对在goqt中使用qss时的注意事项进行说明. 那么事不宜迟,现在开始我们的qss之旅吧. QSS语法入门 qss是一种与css3相似的控制Qt组件的样式表 ...