IF (EXISTS
(
    SELECT name
    FROM sysobjects
    WHERE name = 'FK_PISReceivedPrescriptionDetailIngredients_PISReceivedPrescriptionDetail'
)
   )
    ALTER TABLE dbo.PISReceivedPrescriptionDetailIngredients
    DROP CONSTRAINT FK_PISReceivedPrescriptionDetailIngredients_PISReceivedPrescriptionDetail;

ALTER TABLE dbo.PISReceivedPrescriptionDetailIngredients
ADD CONSTRAINT FK_PISReceivedPrescriptionDetailIngredients_PISReceivedPrescriptionDetail
    FOREIGN KEY (PrescriptionDetailId)
    REFERENCES dbo.PISReceivedPrescriptionDetail (Id) ON UPDATE NO ACTION ON DELETE CASCADE;

