• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 684
  • Last Modified:

How to trigger between 2 servers ?

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
olyrrah
Asked:
olyrrah
  • 4
  • 4
1 Solution
 
ram2098Commented:
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
 
ram2098Commented:
As the above article says,

You can try adding this user information using..

EXEC sp_addlinkedsrvlogin 'TEST1', 'false', 'userLocal', 'userRemote', 'remotePassword'
0
 
olyrrahAuthor Commented:
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
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
olyrrahAuthor Commented:
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
 
ram2098Commented:
Which operating system you are using? I have seen this problem with Windows 2003.
0
 
olyrrahAuthor Commented:
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
 
ram2098Commented:
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
 
olyrrahAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now