0
I would like to create a Trigger in MSSMS (Sql Server) that, if I made an INSERT in table A, with the last record of table B, it would insert 10 more records in table B, and so on whenever I used the last one create 10 more. But I don’t know how to check 'last record', or last object in that table. Would anyone know how to do that?
Are you using an application ? or are you just creating the query to run in sql manager ? Leave as much information as possible so we can help, there are N ways to get the last record in a database, depending on more of what you are using
– Marcos Brinner
I’m creating the query to run in sql manager, but I have an application. I don’t know what information would be interesting.. In my database table A has a Foreignkey of table B as one of the fields.
– Rayane Nascimento
@Rayanenascimento (1) Is there a reason to use trigger procedure to solve this? Could it not be done in the application itself? (2) Could you add in the text of the question details of the tables involved? Just click on the link
editar
, ok? (3) In this process of adding 10 lines in table B it is necessary to be careful with the competition of processes to avoid duplicities...– José Diz
Suggested reading not to fall into the traps of Trigger in SQL Server: https://portosql.wordpress.com/2018/08/18/armadilhas-na-programacao-de-trigger/
– José Diz