IF EXISTS( SELECT * FROM SYS.OBJECTS 
			WHERE NAME ='TRG_EST_NF_ENT_IT_COMPRADOR_EXCLUI_PENDENCIA'AND TYPE = 'TR')
BEGIN
	DROP TRIGGER dbo.TRG_EST_NF_ENT_IT_COMPRADOR_EXCLUI_PENDENCIA 
END
GO
CREATE TRIGGER [dbo].[TRG_EST_NF_ENT_IT_COMPRADOR_EXCLUI_PENDENCIA] ON [dbo].[EST_NF_ENT_IT_COMPRADOR] FOR INSERT AS
DELETE FROM p FROM EST_NF_ENT_IT_PENDENCIA_COMPRADOR p WHERE EXISTS
	(SELECT 
		* 
	FROM 
		INSERTED I
	WHERE 
		I.CD_EMP=p.CD_EMP AND 
		I.CD_FILIAL=p.CD_FILIAL AND 
		I.CD_NF=p.CD_NF AND
		I.CD_PROD = P.CD_PROD)
