[英]dynamic linked server query OLE DB provider “SQLNCLI11” for linked server returned message No transaction is active
iam using sql server 2014 on windows 8.1 pro 我在Windows 8.1专业版上使用sql server 2014
and calling a procedure that calls a dynamic linked server query inside trigger 并调用一个在触发器内调用动态链接服务器查询的过程
(i will not put the complete code but consider it as an algorithm (我不会把完整的代码,但把它当作算法
CREATE PROCEDURE DynamicLinkedQuery(@InstanceName NVARCHAR(32),@DatabaseName NVARCHAR(64),@SchemaName NVARCHAR(64), @TableName NVARCHAR(64))
as
begin
declare
@SqlQuery NVARCHAR(MAX)
Select @SQlQuery='INSERT INTO ['+ @InstanceName+ '].['+@DatabaseName+'].' + @SchemaName + '.' + @TableName + ' Values(3)'
--assuming we have one int columns in destination table
EXECUTE sp_Executesql @SQLQuery
End
because i'm using dynamic linked server query it is considered as distributed query 因为我使用的是动态链接服务器查询,所以它被视为分布式查询
so we have to run Distributed Transaction Coordinator service on both two linked servers 所以我们必须在两个链接的服务器上运行分布式事务处理协调器服务
and of course configuring it first with following steps mentioned in this link 当然,首先使用此链接中提到的以下步骤进行配置
http://www.virtualizationhowto.com/2015/04/ole-db-provider-sqlncli11-linked-server-unable-distributed-transaction/ http://www.virtualizationhowto.com/2015/04/ole-db-provider-sqlncli11-linked-server-unable-distributed-transaction/
but iam still getting the error 但我仍然得到错误
OLE DB provider "SQLNCLI11" for linked server "ServerName" returned message "No transaction is active.". 用于链接服务器“ServerName”的OLE DB提供程序“SQLNCLI11”返回消息“没有事务处于活动状态。”。
but when i execute a non dynamic query like 但是当我执行非动态查询时
INSERT INTO RemoteServerName.RemoteDataBaseName.RemoteSchemaName.RemoteTableName values(1,1) INSERT INTO RemoteServerName.RemoteDataBaseName.RemoteSchemaName.RemoteTableName values(1,1)
every thing is ok and the operation is done 一切都很好,操作就完成了
what can be the reason please and what are my missed configurations in LocalDtc 可能是什么原因请问我在LocalDtc中错过了什么配置
i applied this solution 我应用了这个解决方案
Linked servers SQLNCLI problem. 链接服务器SQLNCLI问题。 "No transaction is active"
“没有交易活跃”
but it never worked for me 但它从来没有对我有用
i discovered that because of my two servers reside in two different domains 我发现因为我的两台服务器位于两个不同的域中
i had to resolve DNS problem 我不得不解决DNS问题
so i put first server name in hosts file in the second server name and my problem was solved 所以我把第一个服务器名称放在第二个服务器名称的hosts文件中,我的问题解决了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.