TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Patrick Rainer
NA
35
2.6k
How to Insert only if value is true
Dec 12 2020 4:39 AM
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
Reply
Answers (
7
)
Set Value of a GENERATED column in a table with if condition in MYSQL
SQL Server - Time Difference in 24-Hour Format