if (exists(select role from sys.sysforeignkey where role='FK_InvOps_Inventory')) then alter table InventoryOperations drop foreign key FK_InvOps_Inventory end if go ALTER TABLE InventoryOperations ADD FOREIGN KEY "FK_InvOps_Inventory" ("InventoryN") REFERENCES "DBA"."Inventory" ("N") ON UPDATE CASCADE ON DELETE CASCADE go if (exists(select role from sys.sysforeignkey where role='FK_InvOps_Guests')) then alter table InventoryOperations drop foreign key FK_InvOps_Guests end if go ALTER TABLE InventoryOperations ADD FOREIGN KEY "FK_InvOps_Guests" ("GuestN") REFERENCES "DBA"."Guests" ("GuestNum") ON UPDATE CASCADE ON DELETE CASCADE go if (exists(select role from sys.sysforeignkey where role='FK_InvOps_Admin')) then alter table InventoryOperations drop foreign key FK_InvOps_Admin end if go ALTER TABLE InventoryOperations ADD FOREIGN KEY "FK_InvOps_Admin" ("AdminN") REFERENCES "DBA"."Admin" ("AdminNo") ON UPDATE CASCADE ON DELETE CASCADE go