Click to See Complete Forum and Search --> : is this CHECK legal?


londondevil
May 11th, 2004, 01:54 PM
I am trying to check an attribute value to see that as long as it exists in one of the tables, it should be ok




CHECK StudentId IN ((SELECT StudentId FROM Enrolment) OR (SELECT StudentId FROM Student))




how else would you code the above, if this isnt legal ?:confused: :confused: :confused:

hspc
May 11th, 2004, 03:14 PM
CHECK constraints can't reference columns in other tables.
there is a solutions in my mind :
create a for insert trigger on the table and check the inserted data.