一个update的触发器
用户要求保留删除的数据,我决定加一个DeleteTime字段,作为标记,deletetime为不为空说明数据已经删除。
create TRIGGER dbo.AfterApplicationDelete
ON dbo.tb_Applications
for update
AS
declare @DeleteTime datetime
set @DeleteTime=(select DeleteTime from inserted)
if(update(DeleteTime) and (@DeleteTime is not null))
begin
update tb_Org_Application
set DeleteTime=getdate()
where AppID in (select [ID] from inserted)
update tb_Process_Application
set DeleteTime=getdate()
where ApplicationID in (select [ID] from inserted)
update tb_Modules
set DeleteTime=getdate()
where ApplicationID in (select [ID] from inserted)
update tb_Org_Process_Application
set DeleteTime=getdate()
where ApplicationID in (select [ID] from inserted)
end
浙公网安备 33010602011771号