I have two tables:
info: ID, fee_id
and
fee: ID, amount
and a reference between them (SQL Server 2008
):
ALTER TABLE info WITH CHECK ADD CONSTRAINT FK_info_fee FOREIGN KEY(fee_id)
REFERENCES fee (ID)
ALTER TABLE info CHECK CONSTRAINT FK_info_fee
GO
How to configure this reference that way so a record in fee
will be deleted if info.fee_id
becomes NULL
EDIT: or maybe set info.fee_id
to NULL
on deleting the corresponding record in fee
.
Anyway I can do it this way:
UPDATE info SET fee = NULL WHERE = ..
DELETE FROM fee WHERE ..
but I'm sure that this can be done by the database itself.