
TRUNCATE TABLE CN_CONTROL_PERIODO
GO

INSERT INTO CN_CONTROL_PERIODO
SELECT *
FROM
(

SELECT 
ROWNUM AS ID_CONTROL_PERIODO,
ID_VIGENCIA,     
ID_PERIODO_CONTABLE,     
ID_CEN_OP,     
ID_CIA,
ACTIVO
FROM(


SELECT DISTINCT
//ID_CONTROL_PERIODO,     
ID_VIGENCIA,     
ID_PERIODO_CONTABLE,     
ID_CEN_OP,     
ID_CIA,     
0 AS ACTIVO  

FROM CN_CONTROL_CAD

ORDER BY 
ID_CIA,    
ID_VIGENCIA,     
ID_PERIODO_CONTABLE,     
ID_CEN_OP

)    

)
