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 |
|
l-jeff@excite.com
Starting Member
39 Posts |
Posted - 2008-05-22 : 10:39:35
|
| i have two tables. 1st table gets the information from as400, then moves the data to table 2 at sql 2000 server. I need to see when as400 updates\changes or inserts new information to table 1 how to update\change or insert into table 2? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-22 : 10:41:29
|
You could make a trigger on table1. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
l-jeff@excite.com
Starting Member
39 Posts |
Posted - 2008-05-22 : 10:50:01
|
| how do i do that? i read info on triggers and can't get it to work.Lisa Jefferson |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-22 : 11:26:48
|
quote: Originally posted by l-jeff@excite.com how do i do that? i read info on triggers and can't get it to work.Lisa Jefferson
Write a trigger on table 1 for UPDATE,DELETE, INSERTIt will be something likeCREATE TRIGGER table_IUD ON table1AFTER INSERT,UPDATE,DELETEASBEGINIF EXISTS (SELECT * FROM INSERTED)AND NOT EXISTS(SELECT * FROM DELETED)BEGININSERT INTO table2SELECT your fields FROM INSERTED iENDIF EXISTS (SELECT * FROM INSERTED)AND EXISTS(SELECT * FROM DELETED)BEGINUPDATE tSET t.field1=i.field1,t.field2=i.field2,...FROM table2 tINNER JOIN INSERTED iON i.FKCol=t.PKColENDIF NOT EXISTS (SELECT * FROM INSERTED)AND EXISTS(SELECT * FROM DELETED)BEGINDELETE t FROM table2 tINNER JOIN DELETED dON d.FKCol=t.PKColENDEND |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|