Dear all
I am trying to insert only if a specific related value is true. I tried the code below, but was not working so far. How can I achieve this in a trigger?
- CREATE TRIGGER CreateTest
- ON Participations
- AFTER INSERT
- AS
- begin
- set nocount on;
- DECLARE @testNeeded bit;
- insert into Tests(participationid)
- values
- ((SELECT i.ParticipationId
- from inserted as i
- inner join Executions on i.ExecutionId = i.ExecutionId
- inner join Courses C on C.CourseId = Executions.CourseId
- where c.TestNeeded = 1))
- end
- go
Patrick



Rajanikant HawaldarRank #110 · 20.2K reputationPosted Dec 11, 2020, 11:53 PM EST
Khaja MoizuddinRank #270 · 9.4K reputationPosted Dec 12, 2020, 12:06 AM EST