Hi

I've been trying to solve the following problem for a few days but everytime I get the error msg even when the entered value doesn't conflict with the statement. Plz I need an urgent help

I have the following tables:

booking
bookingId (PK)
subjectId (FK)

Subject
subjectId (PK)
termId

I want to create a trigger to check the inserted values in booking table . If there's another subject have the same termId as the inserted one I should get an error msg. I tried to do the following but it didn't work

Create Trigger tr_check ON
booking
FOR INSERT, UPDATE
 AS
 BEGIN

IF EXISTS( Select b.bookingId From 
booking b, inserted i, subject s1, subject s2, subject s

WHERe 
	
	 b.subjectId=s1.subjectId AND
	  i.subjectId=s2.subjectId AND
	  s1.subjectId=s.subjectId AND
	  s2.offeringId=s.subjectId AND
	  s1.termId=s2.termId )

Raiserror('ERROR',10,4)
ROLLBACK TRANSACTION
END

Thanx

No response so far :(

i need it urgently

What error do you get when you execute your code? (That would help in figuring out the problem.)

-Brian

Thanx Brian for ur reply. It's too late but I got it worked :)