Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 trigger to update table with data from another box

Author  Topic 

cwfontan
Yak Posting Veteran

87 Posts

Posted - 2008-08-26 : 08:53:26
I would like to know how/ i can create a trigger to update column upon insert to retrieve data from another server.DB ? ?

this is just a stab at what im trying to accomplish
?????????????????????????
update table
set userName =
(SELECT userName FROM server2.db.users WHERE server1.db.userId = server2.db.userID)
????????????????????????

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-26 : 09:58:27
Yes you can, but it can perform very badly and even timeout, thus rollbacking the current statement.
UPDATE		t
SET t.UserName = x.UserName
FROM Table AS t
INNER JOIN inserted AS i ON i.UserID = t.UserID
LEFT JOIN Server2.db.Users AS x ON x.UserID = t.UserID



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

cwfontan
Yak Posting Veteran

87 Posts

Posted - 2008-08-26 : 10:13:29
thank you very much.. also had to use the sp_addlinkedserver [server]
Go to Top of Page
   

- Advertisement -