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

GO
 

CREATE TRIGGER [dbo].[TRG_EST_ALCADA_CP_PED_PEND_DELETE_CANCEL] ON [dbo].[EST_ALCADA_CP_PED_CANCEL] FOR INSERT AS
	BEGIN		
		DELETE FROM EST_ALCADA_CP_PED_PEND
		WHERE EXISTS (SELECT CD_CTR 
					  FROM INSERTED I 
					  WHERE I.CD_CTR = EST_ALCADA_CP_PED_PEND.CD_CTR)	  				
	END								



