Lets say I have a parent table and a lookup table. The parent table references the lookup table. I want to be able to set the parent field to null if I delete the row from the lookup table that it references.
On delete or on cascade isnt working, or I am setting it wrong. I don't want to delete the parent row just update the referenced field to null if I delete the item from the lookup table.
1条答案
按热度按时间vsnjm48y1#
Against my better judgment... I recommend using a "trigger".
When a delete occurs, "update" the other table.
https://learn.microsoft.com/en-us/sql/t-sql/statements/create-trigger-transact-sql?view=sql-server-ver16