hello please i need help with this trigger, i have a trigger that stops a record in a table from being duplicated. each time i insert a record, it fires and raises an error not minding if the condition in the trigger was true or false.pls find trigger belowalter trigger TRG_CHECK_PROGRAMME_COURSE_DUPLICATEOn dbo.Institution_Programme_Coursesfor Insertasdeclare @ProgrammeId int, @CourseId int, @CourseTypeId int, @CourseUnit int, @SemesterId int, @LevelId intselect @ProgrammeId=ProgrammeId, @CourseId=CourseId, @CourseTypeId=CourseTypeId, @CourseUnit=CourseUnit, @SemesterId=SemesterId, @LevelId=LevelIdfrom Insertedif exists( select ProgrammeCourseId from dbo.Institution_Programme_Courses where ProgrammeId=@ProgrammeId AND CourseId=@CourseId AND CourseTypeId=@CourseTypeId AND CourseUnit=@CourseUnit AND SemesterId=@SemesterId AND LevelId=@LevelId ) begin RAISERROR ('This Course SetUp Already Exist, Add New Operation Aborted', 16, 1) rollback tran return end
from this trigger, i am trying to prevent the following record below from repeating twice. (i am avoiding duplicate records)@ProgrammeId,@CourseId,@CourseTypeId,@CourseUnit,@SemesterId,@LevelIdplease what am i doing wrong?nellysoft