IF EXISTS(SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='TELE_ETAPA_VALIDACAO_COMPATIVEL')
BEGIN

	CREATE TABLE #TELE_ETAPA_VALIDACAO_COMPATIVEL  (
			CD_ETAPA_COMPATIVEL int NOT NULL,
			CD_ETAPA int NOT NULL,
			CD_TIPO int not null
			)
			
	INSERT INTO #TELE_ETAPA_VALIDACAO_COMPATIVEL
	VALUES (17, 8, 0),
			(19, 6, 1);


	INSERT INTO TELE_ETAPA_VALIDACAO_COMPATIVEL (CD_ETAPA_COMPATIVEL, CD_ETAPA, CD_TIPO)
	SELECT *
	FROM #TELE_ETAPA_VALIDACAO_COMPATIVEL T
	WHERE NOT EXISTS (SELECT 1 FROM TELE_ETAPA_VALIDACAO_COMPATIVEL B
					  WHERE B.CD_ETAPA_COMPATIVEL = T.CD_ETAPA_COMPATIVEL AND B.CD_ETAPA = T.CD_ETAPA AND B.CD_TIPO = T.CD_TIPO )

drop table #TELE_ETAPA_VALIDACAO_COMPATIVEL	
END