简体   繁体   中英

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

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

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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