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

  • jayrocks20

    SSC Enthusiast

    Points: 146

    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..

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 714105

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

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

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