IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[TRG_EST_NF_ENT_DANFE_PROVISORIO_CONFIRMACAO_RECBTO_EXCLUI_PENDENCIA]'))
DROP TRIGGER [dbo].[TRG_EST_NF_ENT_DANFE_PROVISORIO_CONFIRMACAO_RECBTO_EXCLUI_PENDENCIA]
GO
GO
GO
-----------------------------------INSERCAO EM EST_NF_ENT_DANFE_PROVISORIO_CONFIRMACAO_RECBTO-----------------------------------
CREATE TRIGGER [dbo].[TRG_EST_NF_ENT_DANFE_PROVISORIO_CONFIRMACAO_RECBTO_EXCLUI_PENDENCIA] ON [dbo].[EST_NF_ENT_DANFE_PROVISORIO_CONFIRMACAO_RECBTO] FOR INSERT AS
--Exclui pendencia de confirmacao de romaneio
DELETE 
	FROM p 
FROM 
	EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT_MANIFESTO_PENDENTE p INNER JOIN INSERTED i ON
	p.CD_CTR = i.CD_CTR
WHERE
	p.CD_CTR IS NULL
	
DELETE 
	FROM p 
FROM 
	EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT_CONFIRMACAO_OPERACAO_PENDENTE p INNER JOIN INSERTED i ON
	p.CD_CTR = i.CD_CTR

		