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


Sachin SinghPosted Dec 13, 2020, 2:48 AM
Patrick RainerPosted Dec 13, 2020, 2:11 AM
Sachin SinghPosted Dec 12, 2020, 7:48 AM
Patrick RainerPosted Dec 12, 2020, 5:30 AM
Patrick RainerPosted Dec 12, 2020, 5:08 AM
Khaja MoizuddinPosted Dec 12, 2020, 5:06 AM