473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

linked server referred by insert trigger

Hei,
We have 2 MS SQL SERVER 2000 installed on 2 different servers (2 separated
machines).
I am triing to connect them så that when one row is added to the table in
the database in main server - then the same row is added to the same table
in the second server database.
I made the insert trigger on the table in the first server ( the second
server is added as a linked server):
----------------------------------------------------------------------------
-------------
create trigger ti_myTabe1 on myTable1 for insert as
begin
declare ........
BEGIN
insert into server2.myDatabase2.owner.myTable2
(column1, column2, column3)
SELECT column1, column2, column3
FROM inserted ins
END
......
end
----------------------------------------------------------------------------
-------------

When I run the statement in "SQL Query Analyzer"on the first server:
insert into Table1 values(va1,val2,val3)
then error is coming:

Server: Msg 7391, Level 16, State 1, Procedure ti_myTabe1 , Line 19
The operation could not be performed because the OLE DB provider 'SQLOLEDB'
was unable to begin a distributed transaction.
[OLE/DB provider returned message: New transaction cannot enlist in the
specified transaction coordinator. ]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB'
ITransactionJoin::JoinTransaction returned 0x8004d00a].

The straing thing is: if I run the statement in "SQL Query Analyzer"on the
first server:

insert into server2.myDatabase2.owner.myTable2 values(va1,val2,val3)

then it works!
But not inside the trigger!!! - What I am doing wrong ?

Any idea is greatly appeciated.


Jul 23 '05 #1
2 11703
There is a KB article here:

http://support.microsoft.com/kb/306212

And also a number of newsgroup discussions:

http://groups.google.co.uk/groups?q=...al&sa=N&tab=wg

The trigger requires a distributed transaction because it needs to be
in the same transaction as the statement that fired it, but a single
INSERT stands
alone, as it were. So if distributed transactions aren't working for
any of the reasons described in the KB article, then your trigger won't
either.

If you need to copy a lot of data from one server to another, you might
want to look into replication, although that might be overkill for what
you're doing.

Simon

Jul 23 '05 #2
Hi,

Your
insert into Table1 values(va1,val2,val3)
leads to a single transaction on two servers, because the insert in
table1 and the triggerd insert in server2.myDatabase2.owner.myTable2
by definition (of a trigger) are a single transaction. This is called
a distributed transaction. To be able to run distributed transactions
you should run the DTC service on both servers.

good luck,
Paul
"Elvira Zeinalova" <el**************@sff.no> wrote in message news:<1l*******************@news4.e.nsc.no>...
Hei,
We have 2 MS SQL SERVER 2000 installed on 2 different servers (2 separated
machines).
I am triing to connect them så that when one row is added to the table in
the database in main server - then the same row is added to the same table
in the second server database.
I made the insert trigger on the table in the first server ( the second
server is added as a linked server):
----------------------------------------------------------------------------
-------------
create trigger ti_myTabe1 on myTable1 for insert as
begin
declare ........
BEGIN
insert into server2.myDatabase2.owner.myTable2
(column1, column2, column3)
SELECT column1, column2, column3
FROM inserted ins
END
.....
end
----------------------------------------------------------------------------
-------------

When I run the statement in "SQL Query Analyzer"on the first server:
insert into Table1 values(va1,val2,val3)
then error is coming:

Server: Msg 7391, Level 16, State 1, Procedure ti_myTabe1 , Line 19
The operation could not be performed because the OLE DB provider 'SQLOLEDB'
was unable to begin a distributed transaction.
[OLE/DB provider returned message: New transaction cannot enlist in the
specified transaction coordinator. ]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB'
ITransactionJoin::JoinTransaction returned 0x8004d00a].

The straing thing is: if I run the statement in "SQL Query Analyzer"on the
first server:

insert into server2.myDatabase2.owner.myTable2 values(va1,val2,val3)

then it works!
But not inside the trigger!!! - What I am doing wrong ?

Any idea is greatly appeciated.

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: kevin jin | last post by:
Hi, I did read Andrew's article about SQL Server trigger. After a 'Insert' trigger is fired,is there any way we can modify newly added data in virtual 'Insert' table before put them to the...
4
by: DTB | last post by:
I am having trouble creating an INSTEAD OF trigger in SQL Server to replicate a BEFORE UPDATE trigger from ORACLE. Here is a sample of the ORACLE BEFORE UPDATE trigger: CREATE TRIGGER myTRIGGER ON...
4
by: Hank | last post by:
I have two SQL Server 2000 machines (server_A and server_B). I've used sp_addlinkedserver to link them both, the link seems to behave fine. I can execute remote queries and do all types of neat...
2
by: Brian Salentine | last post by:
Hi - We have two SQL 2000 Servers. We have the linked server setup and we can perform updates and inserts between the databases. But when we add a trigger and insert something into a table, the...
2
by: Steve Kuekes | last post by:
I have two sql servers, I have defined each one as a linked server to the other. I can mostly access the servers from one another, but I get the following error on a sql insert. Insert...
1
by: annie | last post by:
Hi all, I have recently ported my Access 2000 app to SQL Server, keeping the Access client as the front end using linked tables. I am also using triggers on my SQL tables to trap orphan...
8
by: Bri | last post by:
Greetings, I'm having a very strange problem in an AC97 MDB with ODBC Linked tables to SQL Server 7. The table has an Identity field and a Timestamp field. The problem is that when a new record...
2
by: niradjoshi | last post by:
I made two SQL Server 2000 as linked server using same remote login These both server are running on different Domain Configuration Detail 1. Server A - MS SQL Server 2000 SP4, windows 2003...
1
by: madhupk | last post by:
this is regarding C trigger function in postgresql 8.2 The function trigf reports the number of rows in the table ttest and skips the actual operation if the command attempts to insert a null...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.