A colleague came to me today with the question why the performance of a simple ad-hoc delete query was slow. I found out that there was a self referring FK that caused this problem. So this is what I did to make de delete work again.
USE <DATABASE> GO -- 1.Disable CONSTRAINT ALTER TABLE [DBO].[TABLE] NOCHECK CONSTRAINT <FK_Self_RefferingKeyConstraint>; -- 2. Delete records DELETE FROM [DBO].[TABLE] WHERE ID in ( 167364827, 167364828, 167364829, 167364830, 167364831, 167364832, 167364833, 167364834, 167364836, 167364837, 167364838, 167364839, 167364840, 167364841, 167364842 ) -- 3.Enable CONSTRAINT ALTER TABLE [DBO].[TABLE] CHECK CONSTRAINT <FK_Self_RefferingKeyConstraint>; GO