sql truncate table referencing itself code example
Example: sql truncate table referencing itself
-- Original:
UPDATE 'recursive' SET 'parent_id' = NULL WHERE 'parent_id' IS NOT NULL;
DELETE FROM 'recursive';
-- For Example:
UPDATE Items
SET Items.ParentItemId = NULL
WHERE Items.ParentItemId IS NOT NULL;
DELETE FROM Items;
-- Or
TRUNCATE TABLE Items;