IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[TRG_EST_NFE_SOLIC_APROP_CRED_COMB_EST_NFE_LOTE ]'))
	DROP TRIGGER [dbo].[TRG_EST_NFE_SOLIC_APROP_CRED_COMB_EST_NFE_LOTE ]
GO

CREATE TRIGGER [dbo].[TRG_EST_NFE_SOLIC_APROP_CRED_COMB_EST_NFE_LOTE ] ON [dbo].[EST_NFE_SOLIC_APROP_CRED_COMB_EST_NFE_LOTE] 
FOR INSERT 
AS  
	--Excluindo pendencia de carta de correcao.
	DELETE
		pend
	FROM
		INSERTED I 
	INNER JOIN EST_NFE_SOLIC_APROP_CRED_COMB_PEND pend ON
		I.CD_CTR_SOLIC_APROP_CRED_COMB       = pend.CD_CTR_SOLIC_APROP_CRED_COMB      

GO
