You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/word/新协航_设计文档/数据库建表文档/1.0/删除用触发器.sql

29 lines
914 B
Transact-SQL

--删除用触发器
--删除合同时,删除货物信息、单据、应收应付
--删除货物信息时,删除许可证使用、库存
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