--删除用触发器 --删除合同时,删除货物信息、单据、应收应付 --删除货物信息时,删除许可证使用、库存 IF EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[tri_delMain]')) DROP TRIGGER [dbo].[tri_delMain] GO create trigger tri_delMain on import_Main after delete as begin delete from import_cargo where contractno in(select deleted.contractno from deleted) delete from import_receipt where contractno in(select deleted.contractno from deleted) delete from ch_fee where bsno in(select deleted.contractno from deleted) end go IF EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[tri_delcargo]')) DROP TRIGGER [dbo].[tri_delcargo] GO create trigger tri_delcargo on import_cargo after delete as begin delete from import_appstate where contractno in(select deleted.contractno from deleted) delete from import_KC where contractno in(select deleted.contractno from deleted) end go