title: How to create a trigger for delete from referenced tables in SQL Server
body: <p>Hello we have recently learned how to create triggers and I have to do one on delete from Users, which also deletes said user from referenced tables but I don't know how to make it in SQL server (we had to choose a DB Management system and I chose sql server) but I recently learned you can't do triggers before the action so I don't know how to solve this, I had something like</p>
  <pre><code>create trigger myTrigger
  on User
  for delete
  AS
  delete from GroupParticipants where participantId in (select deleted.codUser from Deleted)
  delete from (...) where column in (select deleted.codUser from Deleted)
  GO
  </code></pre>
  <p>Yet, as this happens after the delete, said delete never occurs due to referential integrity, how do I solve this seemingly simple problem?</p>
  <p>My tables are something like this:</p>
  <blockquote>
  <p>User (codUser, ...)</p>
  <p>GroupParticipant (groupId, codUser)</p>
  <p>OtherTable(codUser)</p>
  </blockquote>
  <p>and other irrelevant tables</p>