/****** Object:  Trigger [TRG_EST_NF_ENT_EST_NF_SAI_TRANSF_EXCLUI_ERROS_VALIDACAO]    Script Date: 30/04/15 11:46:53 ******/
IF EXISTS
(SELECT * FROM sys.triggers
    WHERE object_id = OBJECT_ID(N'[dbo].[TRG_EST_NF_ENT_EST_NF_SAI_TRANSF_EXCLUI_ERROS_VALIDACAO]')
)
    DROP TRIGGER  [dbo].[TRG_EST_NF_ENT_EST_NF_SAI_TRANSF_EXCLUI_ERROS_VALIDACAO];
GO
GO
-----------------------------------INSERÇÃO EM EST_NF_SAI_ERROS_VALIDACAO-----------------------------------

CREATE TRIGGER [dbo].[TRG_EST_NF_ENT_EST_NF_SAI_TRANSF_EXCLUI_ERROS_VALIDACAO] ON [dbo].[EST_NF_ENT_EST_NF_SAI_TRANSF]
FOR INSERT
AS
--Exclui pendência de entrada de nota fiscal 
     DELETE FROM p
     FROM 
		EST_NF_SAI_ERROS_VALIDACAO p 
		join INSERTED i on 
			i.CD_EMP		= p.CD_EMP
		AND i.CD_FIL_ORIG	= p.CD_FILIAL
		AND i.CD_NF_SAI		= p.CD_NF