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
br
Patrick