/****** Object:  Trigger [TRG_EST_NF_ENT_PRE_ENTRADA_EST_NF_ENT_EXCLUI_PENDENCIA]    Script Date: 05/08/2014 14:54:07 ******/
IF EXISTS(SELECT NAME FROM SYS.TRIGGERS WHERE NAME = 'TRG_EST_NF_ENT_PRE_ENTRADA_EST_NF_ENT_EXCLUI_PENDENCIA')
BEGIN
	DROP TRIGGER [dbo].[TRG_EST_NF_ENT_PRE_ENTRADA_EST_NF_ENT_EXCLUI_PENDENCIA]
END
GO
GO
GO
-----------------------------------INSERÇÃO EM EST_NF_ENT_PRE_ENTRADA_EST_NF_ENT-----------------------------------
CREATE TRIGGER [dbo].[TRG_EST_NF_ENT_PRE_ENTRADA_EST_NF_ENT_EXCLUI_PENDENCIA] ON [dbo].[EST_NF_ENT_PRE_ENTRADA_EST_NF_ENT] FOR INSERT AS
DELETE FROM p FROM EST_NF_ENT_PRE_ENTRADA_PENDENCIA p WHERE EXISTS
    (SELECT * FROM INSERTED WHERE CD_EMP=p.CD_EMP AND CD_CTR_PRE_ENTRADA=p.CD_CTR_PRE_ENTRADA)
GO