It is an exam question to be honest. I have found a workaround for it. That is temporarily deleting the foreign key constraint, then re-creating it again. Of course it sounds stupid, but in reality, no one is insane enough to change the ID of a table. I guess I have to use stupid query to deal with stupid exam question. One thing though, how do I loop through the inserted and deleted table if multiple rows are updated? Is there any for loop in SQL?