armanpour
پنج شنبه 21 مرداد 1389, 14:42 عصر
با سلام
من دو تا جدول دارم ، یکی برای مشخصات دانشجو با کلید اصلی ID و دیگری برای نمرات دانشجو با کلید خارجی ID
حالا یک تریگر نوشتم به این صورت
create trigger tr_delete1 on Student
after Delete
as
declare @StID int
select @StID=ID from deletedbegin
delete from degrees where degrees.ID=@StID
end
go
delete from Student where ID='4'
اما زمان اجرا این خطا رو میده
The DELETE statement conflicted with the REFERENCE constraint "fk_Degrees". The conflict occurred in database "Fridaydb", table "dbo.Degrees", column 'ID'.
چطور میتونم این مشکل رو بر طرف کنم؟
با سپاس
من دو تا جدول دارم ، یکی برای مشخصات دانشجو با کلید اصلی ID و دیگری برای نمرات دانشجو با کلید خارجی ID
حالا یک تریگر نوشتم به این صورت
create trigger tr_delete1 on Student
after Delete
as
declare @StID int
select @StID=ID from deletedbegin
delete from degrees where degrees.ID=@StID
end
go
delete from Student where ID='4'
اما زمان اجرا این خطا رو میده
The DELETE statement conflicted with the REFERENCE constraint "fk_Degrees". The conflict occurred in database "Fridaydb", table "dbo.Degrees", column 'ID'.
چطور میتونم این مشکل رو بر طرف کنم؟
با سپاس