Skip to content
Advertisement

While updating table1, how do I INSERT to table2 for every change in table 1?

I have a MEMBER table and NOTIFICATION table. On client side, I list all of the records in MEMBER table and there is a points column and this is shown as text input. So after I change the values for some members, I can click save button and this will update the records in my MEMBER table that’s all right,

But the thing I want to accomplish is for every record whose points value has changed I want to INSERT a record in my notifications table.

I couldn’t think of anything, how can I approach to this problem?

For notifications I made 3 tables by following the article in here

Advertisement

Answer

Use the output clause instead of trigger, they are bad.

You need the condition “where data_old <> data_new” case if you updated a column with the same value, SQL Server marked it as changed, even if the value hasn’t changed

will result with this in #audit :

enter image description here

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement