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.
Author |
Topic |
abyie
Starting Member
42 Posts |
Posted - 2006-12-27 : 10:16:10
|
Hi, I am in bit of mess and need your help.I have created a trigger which gets fired when a field A on Table 1 located on database A gets updated.The trigger then imports fields from Table 1 related to that record to a new Table 2 located on Database B.IssueRight now, whenever field A is updated, it inserts all the fields into the Table 2.So if field A is updated twice for the same record it will insert twice all the fields into Table 2 which I do not want.It should only insert the records if the field A is updated and there is no previous record for the same ID.Any help would be greatly appreciated.Thanks--------Abyie |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-12-27 : 10:26:11
|
[code]Create Trigger xxxon Table1for UpdateasbeginIf not exists(select * from databaseB..table2 t1 Join Inserted t2 on t1.ID = t2.ID) Insert into databaseB..table2 ....end[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
abyie
Starting Member
42 Posts |
Posted - 2006-12-27 : 11:55:23
|
Thanks Harsh, It worked beautifully for me..Thanks for your help.Cheers |
 |
|
|
|
|