I need take the id of anexo an then the result id list insert in another table
with new_id as(INSERT INTO
clienteproveedor.anexo
(
codigo,
estado,
facturar,
observaciones,
servicioproductocontratadoid,
formaspagoid
)
select
ServiciosPorAnexo.CodAnexo,
ServiciosPorAnexo.cancelado,
serviciosporanexo.facturacion,
ServiciosPorAnexo.MotivosElim,
ServiciosPorAnexo.codigo_servicio,
ServiciosPorAnexo.FormaPago
from clienteproveedor.serviciosporanexo
returning id);