如何從表中刪除行,如果它有外鍵? 我有這個存儲過程,但是當我執行它時,它給了我這個錯誤:The DELETE statement conflicted with the REFERENCE constraint "FK__Pilot_Fli__pilot__4E88ABD4". The conflict occurred in database "Airline Reservation", table "dbo.Pilot_Flight", column
'pilot_id'。從Sql Server中的表中刪除行
create procedure DeletePilot
(@id INTEGER,@result varchar(70) output)
as
If NOT Exists (Select * From Pilot
Where [email protected])
Begin
Set @result='There is no record with that ID'
RETURN
END
Delete from Pilot
where [email protected]
set @result='Record was deleted'
RETURN
GO
select * from Pilot
Declare @res varchar(70)
EXEC DeletePilot 7,@res OUTPUT
print(@res)
任何人都可以幫助我!
第二個工作。謝謝 – user3043278
@ user3043278,我很高興我可以幫助! –