/*IF EXISTS ( SELECT *
	          FROM SYS.TRIGGERS
			 WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[TRG_TELE_ORC_ECOMMERCE_PEND_RESSUP]')
		  )
	DROP TRIGGER [DBO].[TRG_TELE_ORC_ECOMMERCE_PEND_RESSUP];
 GO
 
CREATE  TRIGGER [dbo].[TRG_TELE_ORC_ECOMMERCE_PEND_RESSUP] ON [dbo].[INTEGRA_ECOMMERCE_PEDIDO] 
FOR INSERT AS

--IF NOT UPDATE(CD_ETAPAS) 
--	RETURN;

	INSERT INTO TELE_ORC_ECOMMERCE_PEND_RESSUP (CD_ORC, CD_ETAPAS, DT_CAD)
	SELECT 
		CD_ORC,
		0 CD_ETAPAS, 
		GETDATE()
	FROM 
		INSERTED p
	WHERE 
		NOT EXISTS (SELECT * FROM	
						TELE_ORC_ECOMMERCE_PEND_RESSUP WHERE  p.CD_ORC=CD_ORC);
		

*/