OLe DB provider “SQLNCLI” for linked server was unable to begin a distributed transaction

匿名 (未验证) 提交于 2019-12-03 08:44:33

问题:

I am trying to call a stored procedure in SQL Server 2008 and store the fetched data into a local temp table.

When I try to run it, I receive the following error:

The operation could not be completed because OLe DB provider "SQLNCLI" for linked server was unable to begin a distributed transaction

My code is as follows :

create table #temp(     col1 as int,     col2 as varchar(50) )  insert into #temp exec [192.168.0.9].[db1].[dbo].[tablename] @usr_id=3 

回答1:

You can prevent using distributed transactions for the linked server by setting server option 'remote proc transaction promotion' to 'false':

EXEC sp_serveroption 'servername', 'remote proc transaction promotion', 'false' 

Here's the same issue



回答2:

linked server was unable to begin a distributed transaction errors are because of issues in MSDTC (MS distributed transaction coordiinator). Issues can arise from a number of problems. Including MSDTC not running, being blocked by firewall, and others.

If you require transactions, you have to debug the problem pretty much yourself since it is environmental. If you can rewrite to avoid requiring a transaction your life will be simpler. Just to make sure it is a MSDTC issue, write a simple query that will not depend on MSDTC. e.g.

create table #temp( col1 as int, col2 as varchar(50) )  insert into #temp  select col1, col2 from [192.168.0.9].[db1].[dbo].[tablename] where usr_id=3 

If this works, its definitely MSDTC (and perhaps an avoidable problem)

-- Added this. Spent a little while looking for MSDTC debugging. http://www.sqlwebpedia.com/content/msdtc-troubleshooting was pretty good as was http://www.mssqltips.com/sqlservertip/2083/troubleshooting-sql-server-distributed-transactions-part-1-of-2/ togehter they cover just about every thing I can recall having to debug for MSDTC problems (and some others too).



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!