FacebookTwitter
Hatrack River Forum   
my profile login | search | faq | forum home

  next oldest topic   next newest topic
» Hatrack River Forum » Active Forums » Books, Films, Food and Culture » SQL Server 2005 question on linked servers.

   
Author Topic: SQL Server 2005 question on linked servers.
Slim
Member
Member # 2334

 - posted      Profile for Slim   Email Slim         Edit/Delete Post 
Here is my problem. I have a database on my local machine. Part of what I need to do is connect this database with another database across the internet.

I can set up the linked server fine, and it connects all right. I can, for example execute
SELECT * FROM Linked_Server_Name.Database_Name.dbo.TableName
and I get everything from TableName. I can also perform an INSERT INTO statement, and it works correctly.

The problem I run into, however, is that when this code is in a Trigger. I put PRINT statements to see where it crashes, and it first does a SELECT just fine, but afterwards it does an INSERT, and that is where it fails. (executing the exact same INSERT statement outside the trigger works perfectly.)

The error message I get is:
Msg 7391, Level 16, State 2, Procedure tr_InsertBilling, Line 58
The operation could not be performed because OLE DB provider "MSDASQL" for linked server "TITAN_LAW" was unable to begin a distributed transaction.

Any help will be much appreciated. Thank You.

Posts: 172 | Registered: Aug 2001  |  IP: Logged | Report this post to a Moderator
TomDavidson
Member
Member # 124

 - posted      Profile for TomDavidson   Email TomDavidson         Edit/Delete Post 
Try starting a simple SELECT stored procedure with "BEGIN TRANSACTION." Does this cause the error to occur?

Is the DTC or MSDTC service active on both servers?

Are you setting XACT_ABORT ON?

Posts: 37449 | Registered: May 1999  |  IP: Logged | Report this post to a Moderator
Slim
Member
Member # 2334

 - posted      Profile for Slim   Email Slim         Edit/Delete Post 
Okay, I wrote a stored procedure using "BEGIN TRANSACTION" that only contained a select statement from the linked server. That worked fine. I tried it again, changing the SELECT to an INSERT and it failed.

DTC is on at my end. I don't know about the other end, but I assume it is, because the other students projects were able to work that also used linked servers. Unless there's something specific about my database hosted at the school computer (that I am linking to) the problem shouldn't be at that end.

I am not setting XACT_ABORT ON. I read something about that, but I wasn't able to really tell how/where to use it. Is that my problem?

Posts: 172 | Registered: Aug 2001  |  IP: Logged | Report this post to a Moderator
TomDavidson
Member
Member # 124

 - posted      Profile for TomDavidson   Email TomDavidson         Edit/Delete Post 
Although it's been a while, I'm pretty sure XACT_ABORT is required for all data change transactions between OLEDB providers.
Posts: 37449 | Registered: May 1999  |  IP: Logged | Report this post to a Moderator
Slim
Member
Member # 2334

 - posted      Profile for Slim   Email Slim         Edit/Delete Post 
After what you said, I tried looking up how to use XACT_ABORT, but nothing was very helpful on how to use it.

I tried adding SET XACT_ABORT ON in various places in that test stored procedure I wrote, but nothing made a difference.

Either I'm using it wrong, or there is still something else that is the problem. ...

Posts: 172 | Registered: Aug 2001  |  IP: Logged | Report this post to a Moderator
TomDavidson
Member
Member # 124

 - posted      Profile for TomDavidson   Email TomDavidson         Edit/Delete Post 
Here's the relevant KB article:
http://support.microsoft.com/kb/306212

I personally suspect a DTC error. It's very common for people to not have MSDTC network access installed on Win2K3, since it's now deactivated by default. There's a brief post about that issue here:
http://blogs.msdn.com/florinlazar/archive/2003/12/04/enable-network-dtc-access-in-windows-server-2003.aspx

And the KB article about that issue:
http://support.microsoft.com/kb/817064

Posts: 37449 | Registered: May 1999  |  IP: Logged | Report this post to a Moderator
Slim
Member
Member # 2334

 - posted      Profile for Slim   Email Slim         Edit/Delete Post 
Thanks. I'll get in contact with the teacher about it.
Posts: 172 | Registered: Aug 2001  |  IP: Logged | Report this post to a Moderator
   

   Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


Contact Us | Hatrack River Home Page

Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2