A
A
alexei_20022021-06-14 15:20:02
SQL Server
alexei_2002, 2021-06-14 15:20:02

Trigger to delete records in a linked table?

Table Students
60c748a733d0f074808229.png

table Marks
60c748e8b3d95163771526.png
You need to create a delete trigger that, when a student is deleted, deletes all of their grades.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2021-06-14
@alexei_2002

You need to create a delete trigger
Not necessary.
Do a cascade delete. For example:
ALTER TABLE [dbo].[PerformerGenre]
    WITH NOCHECK ADD CONSTRAINT [FK_PerformerGenre_Genre] FOREIGN KEY([Genre])
  REFERENCES [dbo].[Genre] ([ID])
  ON DELETE CASCADE

required in coursework
CREATE TRIGGER deleted_otmetki ON student FOR DELETE
AS 
DELETE FROM otmetki WHERE otmetki.kod_studenta = deleted.kod_studenta
GO

Guide .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question