IF EXISTS( SELECT * FROM SYS.OBJECTS 
			WHERE NAME ='TRG_EST_NF_ENT_DANFE_PROVISORIO_EST_PED_CP_EXCLUI_PENDENCIA'AND TYPE = 'TR')
BEGIN
	DROP TRIGGER dbo.TRG_EST_NF_ENT_DANFE_PROVISORIO_EST_PED_CP_EXCLUI_PENDENCIA 
END

/****** Object:  Trigger [dbo].[TRG_EST_NF_ENT_DANFE_PROVISORIO_EST_PED_CP_EXCLUI_PENDENCIA]    Script Date: 25/11/2014 17:12:12 ******/
SET ANSI_NULLS ON 
GO
SET QUOTED_IDENTIFIER ON 
GO

CREATE TRIGGER [dbo].[TRG_EST_NF_ENT_DANFE_PROVISORIO_EST_PED_CP_EXCLUI_PENDENCIA] ON [dbo].[EST_NF_ENT_DANFE_PROVISORIO_EST_PED_CP] FOR  INSERT AS
BEGIN
	  
	-- Sem pedido	
	DELETE p
		FROM EST_NF_ENT_DANFE_PROVISORIO_SEM_PEDIDO p 
		INNER JOIN INSERTED i ON
		p.CD_CTR = i.CD_CTR

END 


