Risks/drawbacks of using ALTER TABLE NOCHECK CONSTRAINT FK_XXX on production system ???

  • I have a selfreferenced foreignkey table . Deleting records from this table is complicated.

    I am using a CTE to fetch all child records to be deleted together to avoid foreign key constraint error however it has performance issues and locks the table for long.

    as an alterative I though of :

    ALTER TABLE

    NOCHECK CONSTRAINT FK_XXX

    DELETE FROM TABLE WHERE XXX

    ALTER TABLE CHECK CONSTRAINT FK_XXX

    I want to know the Risks/ drawbacks involved in using this ALTER TABLE NO CHECK CONSTRAINT on production servers.

    Thanks..

  • The immediate risk is that you write a poor query and delete the wrong data.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply