Solved

How to trigger between 2 servers ?

Posted on 2004-09-28
8
611 Views
Last Modified: 2008-02-01
Hi,

I have 2 different physical servers, "Server A" & "Server B" (Referred as ip address).
Upon insertion of new record in "Table A" at "Server A" i would also like to "auto insert" the same record to "Table B" at "Server B".

Below is my trigger script, wat is wrong with it ?

CREATE TRIGGER TriggerInsert
ON TableA
FOR INSERT
AS
  insert into "IPAddressOfServerB".DatabaseNameOfServerB..TableB(...) select ... FROM Inserted

When i run this SQL returns me : Could not find server (ip address) in sysservers. Execute sp_addlinkedserver to add the server to sysservers ...

I have also tried adding this :

exec sp_addlinkedserver
   @server = 'IPAddressOfServerB',
   @provider = 'MSDASQL',
   @provstr = 'DRIVER={SQL Server};SERVER=IPAddressOfServerB;UID=XXX;PWD=XXX;'

After that SQL returns me another msg : User does not have permission to perform this action.

Can anyone advise. Thanks

0
Comment
Question by:olyrrah
  • 4
  • 4
8 Comments
 
LVL 11

Expert Comment

by:ram2098
ID: 12168732
You need to more configuration settings for this.. Right Click on the Linked Server from Enterprise Manager and then add the userid information there...

See the following link..it will suggest you how to setup this information.

http://www.databasejournal.com/features/mssql/article.php/3116011

0
 
LVL 11

Expert Comment

by:ram2098
ID: 12168753
As the above article says,

You can try adding this user information using..

EXEC sp_addlinkedsrvlogin 'TEST1', 'false', 'userLocal', 'userRemote', 'remotePassword'
0
 

Author Comment

by:olyrrah
ID: 12176764
Thanks for the feedback, I have followed the instruction to setup linked server on Server A and i can successfully do a select query on the table from Server B but the problem is i still cannot trigger the insert, the operation hang when i do so ... pls advise.

Fyi, I have done the followings :

1. At Server A add a linked server.
Linked Server : (Server B IP Address)
Server Type : SQL Server
Security : Be made using this security context. I use one of the account from database B

2. Created a trigger at Server A

CREATE TRIGGER TriggerInsert
ON TableA
FOR INSERT
AS
  insert into "ServerBIPAddress".DatabaseB.dbo.TableB(...) select ...FROM Inserted

3. Tested a query from Server A query analyzer

select * from "ServerBIPAddress".DatabaseB.dbo.TableB

The query works fine and it returns me the result immediately.

The final thing that i tried is to insert a record in TableA (at Server A) and the operation went forever with no record being inserted

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:olyrrah
ID: 12176779
I have also tried the statement at Server A :

insert into "ServerBIPAddress".DatabaseB.dbo.TableB(...) values(...) and it also turns out correctly with a record being inserted into the table at Server B
0
 
LVL 11

Expert Comment

by:ram2098
ID: 12176804
Which operating system you are using? I have seen this problem with Windows 2003.
0
 

Author Comment

by:olyrrah
ID: 12176818
Server A is win2k but Server B is 2003 ... so its something to do with the server compatibility ? Btw is there anything wrong with the procedures i have taken ?
0
 
LVL 11

Accepted Solution

by:
ram2098 earned 250 total points
ID: 12176825
I haven't seen any issue with the existing one...

But, fix the issue from Windows 2003 side as well...

Please look at the following link.... (sorry...I have tried both windows 2003 and both windows 2000 before..but not tried the combination..not sure whether it really resolves this issue). You have to take care of the following instructions anyway.

http://dvhome.co.uk/blog/archive/2004/03/22/205.aspx
0
 

Author Comment

by:olyrrah
ID: 12187301
Thanks for the solution, though i didnt really take the last step as i really short of time analyzing the problem so i just use a scheduled dts for that and it does the same objective just that without immediately. Maybe next time ... when i have the opportunity to have 2 server with the same os :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read about achieving the basic levels of HRIS security in the workplace.
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question