简体   繁体   English

将结果集插入到临时表中时,SQL Server 2005 DB2链接的服务器错误

[英]SQL Server 2005 DB2 Linked Server Error When Inserting Result Set into a Temp Table

We have a linked Server against DB2 on SQL Server 2005. When we tried putting a simple query result set from the linked sever into a temp table return this error. 我们在SQL Server 2005上有一个针对DB2的链接服务器。当我们尝试将来自链接服务器的简单查询结果集放入临时表时,将返回此错误。

OLE DB provider "MSDASQL" for linked server "SOMEDSN" returned message "[IBM][CLI Driver] SQL0998N Error occurred during transaction or heuristic processing. Reason Code = "16". Subcode = "2-8004D026". SQLSTATE=58005 ". 链接服务器“ SOMEDSN”的OLE DB访问接口“ MSDASQL”返回消息“ [IBM] [CLI驱动程序] SQL0998N在事务或启发式处理期间发生错误。原因代码=” 16“。子代码=” 2-8004D026“。SQLSTATE = 58005” 。 Msg 7391, Level 16, State 2, Line 21 The operation could not be performed because OLE DB provider "MSDASQL" for linked server "SOMEDSN" was unable to begin a distributed transaction. 消息7391,级别16,状态2,第21行,因为链接服务器“ SOMEDSN”的OLE DB提供程序“ MSDASQL”无法启动分布式事务,所以无法执行该操作。

DECLARE @FilterCode varchar(20);
Set @FilterCode = '11122';

Create Table #TmpTable (
    Id Int
)

Insert Into #TmpTable
EXEC ('Select A.Id From SCM1.DB2TBL1 A Where A.FilterCode = ?', @FilterCode) At SOMEDSN;

The Exec works just fine with correct result set displayed, but as soon as we tried the result set into the temp table, then we get the error. Exec可以正常工作,并显示正确的结果集,但是一旦我们将结果集尝试到temp表中,我们就会收到错误消息。

I searched here and many other places and tried the followings. 我在这里和其他许多地方搜索并尝试了以下方法。

  1. sp_configure 'remote proc trans', 0 sp_configure'远程proc传输',0
  2. On Linked Server Properties > Server Options set "Enable Promotion of Distributed Transactions" to false. 在“链接服务器属性”>“服务器选项”上,将“启用促销分布式事务”设置为false。 I did not see this option. 我没有看到此选项。
  3. On Linked Server Properties > RPC, RPC out and distributor are set to value TRUE 在“链接服务器属性”>“ RPC”上,“ RPC输出和分发服务器”设置为值TRUE。
  4. Used Openquery, but it cannot use dynamic SQL or pass parameters. 使用了Openquery,但不能使用动态SQL或传递参数。

The table contains very many rows. 该表包含很多行。 We need to execute the query on the DB2 side to reduce the result set based on the parameter. 我们需要在DB2端执行查询以减少基于参数的结果集。

Any help would be greatly appropriated! 任何帮助将不胜枚举!

Have you started the MSDTC service (DTC)? 您是否已启动MSDTC服务(DTC)?

Under Windows 2008: 在Windows 2008下:

  • From Administrative tools->Component services->Computers->My computer: Local DTC. 从管理工具->组件服务->计算机->我的计算机:本地DTC。 Right click Properties, go to the MSDTC tab and select "Security Configuration". 右键单击属性,转到MSDTC选项卡,然后选择“安全配置”。
  • Enable checkbox for "Network dtc access" and "Allow outbound". 启用“网络dtc访问”和“允许出站”复选框。
  • Enable checkbox for "No Authentication Required" 启用“不需要身份验证”复选框

If that does not work, try disabling connection pooling . 如果这样不起作用,请尝试禁用连接池

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM