I need to create trigger that add new row in table when the value in other table is upadated. For example, If I change the value into 5 in table1, I need to create in other table (table2) five (5) new row with some values of table1 (for example ID or get also other value).
Example: Table1
ID Date Flag NumberOfNewRowsInTable2
1 17/07/2017 1 0
When change into 5 the value of column "NumberOfNewRowsInTable2" I need to create in Table2 new five rows:
Table2
ID Field1 Field2
1 X Y
1 X Y
1 X Y
1 X Y
1 X Y
Thank you all, sorry for my bad explain.I use SQL Server. Now I try to explain it better. I need to create a payment by instalments and so I want the user to choose a number of instalments and automatically I would have in the table2 (payment instalments table) the equivalent number of rows (one for each instalments) . Now, for example: There is the Table1. In the Table1 there is an ID field and I can choose the type of payments for the record. When the user choose the payment by instalments, he can choose also the number of instalments. When the user select the desired number of instalments, automatically I would have in the table2 (payment instalments table) the equivalent number of rows (one for each instalments) and the corrisponding ID (in the field ID of Table2). The other problem is this: when user remove the payment by instalments and insert other kind of payment, I need to remove it from the Table2. Moreover, if the user change the number of instalments, I need to adjust the rows with the new equivalent number of instalments. I hope to explain it better and thank you all for your answers. Andrea
It is possible to do this with a trigger? Thank you all, Andrea.