Trigger - insert into one table update into another table

If i insert record in table A and these record should update in table B by using Trigger.How to achieve this.
Trigger - insert into one table update into another table

Showing Answers 1 - 4 of 4 Answers

Abhay J

  • Jan 18th, 2015

You can create the trigger before/after insert on A for each row in which you can write the code to update the table B.

  Was this answer useful?  Yes


  • Apr 29th, 2015

We can insert into one table and update another table....but what if ? ..this case :insert into table A, update Table b and then again insert into Table A and update table B ...isnt this becoming a round about phenomenon and a cascading trigger ....please, somebody clarify this....

  Was this answer useful?  Yes


  • Aug 10th, 2015

We can use instead of trigger in this case

  Was this answer useful?  Yes


  • Sep 10th, 2015

  1. CREATE  TRIGGER  update_trigger

  2. ON CUSTOMER_info



  5. BEGIN

  6.     IF UPDATE (cust_name) OR UPDATE (contact)

  7.     BEGIN

  8.         INSERT INTO update_log (

  9.             cust_no

  10.             ,Cust_name

  11.             ,Contact

  12.             ,Date

  13.             )

  14.         SELECT cust_no

  15.             ,cust_name

  16.             ,contact

  17.             ,GetDate()

  18.         FROM INSERTED


  20.         INSERT INTO update_log (

  21.         cust_no

  22.         ,Cust_name

  23.         ,Contact

  24.         ,Date

  25.         )

  26.     SELECT cust_no

  27.         ,cust_name

  28.         ,contact

  29.         ,GetDate()

  30.     FROM DELETED

  31. END

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions