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