I have a stored procedure that deletes a record from a table where one of the columns matches a specified value:
ALTER PROCEDURE [dbo].[Sp_DelBranch] @datafield varchar(50)
AS
BEGIN
DELETE FROM Branch WHERE branchname = @datafield
END
Unfortunately I get the following error on execution:
The DELETE statement conflicted with the REFERENCE constraint "fk_BranchIdDept". The conflict occurred in database "MproWorkSpace", table "dbo.Department", column 'BranchId'.
Can anyone explain why I'm seeing this error?