/****** Object:  Trigger [TRG_EST_NF_ENT_DANFE_PROVISORIO_ITENS_VALIDACAO_IMPOSTO_EXCLUSAO]    Script Date: 07/05/2014 11:44:15 ******/
IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[TRG_EST_NF_ENT_DANFE_PROVISORIO_ITENS_VALIDACAO_IMPOSTO_EXCLUSAO]'))
DROP TRIGGER [dbo].[TRG_EST_NF_ENT_DANFE_PROVISORIO_ITENS_VALIDACAO_IMPOSTO_EXCLUSAO]
GO
GO
GO

CREATE TRIGGER [dbo].[TRG_EST_NF_ENT_DANFE_PROVISORIO_ITENS_VALIDACAO_IMPOSTO_EXCLUSAO] ON [dbo].[EST_NF_ENT_DANFE_PROVISORIO_ITENS_VALIDACAO_IMPOSTO] 
FOR INSERT
AS
	--Deletando caso existia o registro
	DELETE 
		p
	FROM 
		EST_NF_ENT_DANFE_PROVISORIO_ITENS_VALIDACAO_IMPOSTO_PENDENTE p INNER JOIN INSERTED i ON
		p.CD_CTR = i.CD_CTR AND
		p.CD_CTR_IT = i.CD_CTR_IT 
	--Fim
