IF OBJECT_ID(N'[dbo].[FK_PL_ViewPL_LinkOrder]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PL_LinkOrder] DROP CONSTRAINT [FK_PL_ViewPL_LinkOrder];
GO

-- Creating foreign key on [ViewID] in table 'PL_LinkOrder'
ALTER TABLE [dbo].[PL_LinkOrder]
ADD CONSTRAINT [FK_PL_ViewPL_LinkOrder]
    FOREIGN KEY ([ViewID])
    REFERENCES [dbo].[PL_View]
        ([ViewID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO