﻿CREATE PROCEDURE [dbo].[MIGRAZIONEPDF1]
AS
BEGIN
insert into migrareport 
SELECT top 100000 m.id,v.chiaveclientepb,null as dt
      from (SELECT * FROM repositoryMetadati  where  tipoReport in (1,3,4) and idCliente <> 319 and repository in (4,0) ) m  
      join [CONSEVO].ConsulenzaBase.dbo.vInfoCliente v on v.rete=m.rete and v.codfis=m.cod_fiscale and v.agente = m.cod_agente
      left join migrareport r on r.id = m.id
      where r.id is null
 --SELECT * FROM migrareport
END