UPDATE AcuCuentasCc SET IdSubCos='-1' WHERE TipoAcum='CC' 
GO
INSERT INTO AcuCuentasCc (nAnno,nMes,IdCia,IdCuenta,IdCCosto,IdSubCos,TipoAcum,SaldoAnterior,TotalDebitos,TotalCreditos)
SELECT nAnno,nMes,A.IdCia,A.IdCuenta,A.IdCCosto,'-1','CC',SUM(SaldoAnterior),SUM(TotalDebitos),SUM(TotalCreditos)
FROM AcuCuentasCc AS A INNER JOIN Puc AS P ON A.IdCuenta=P.IdCuenta
WHERE TipoAcum='CS' AND CentroCosto<>0 AND SubCentro<>0
GROUP BY nAnno,nMes,A.IdCia,A.IdCuenta,A.IdCCosto
GO