悬赏园豆:20
[已解决问题]
解决于 2008-03-24 11:14
<P>说明:studnet 表中外键CourseID为Course表中的主键,当删除Course表中的CourseID时,对应Studnet表中的也被删除。 <BR>下面这个有错误,我觉的是违反了主外键的一些规则,该怎么写啊? <BR>Create Trigger Delete_ID <BR>On Course <BR>for delete <BR>as </P>
<P>DECLARE @CourseID int <BR><BR>select @CourseID = CourseID FROM Course deleted <BR><BR>IF EXISTS (Select * from Student where CourseID = @CourseID) <BR>begin<BR>delete From Student where Student.CourseID=deleted.CourseID <BR>end</P>
<P></CD></P>