CREATE procedure [C6StagingPeriodico].[REPTRIM_WSEIAN2]  
AS 
BEGIN  
exec [C6StagingPeriodico].[RP_W6LogBatch] 'Replica WSEIAN2'
TRUNCATE TABLE [C6StagingPeriodico].[WSEIAN2]
INSERT INTO [C6StagingPeriodico].[WSEIAN2]
           ([DTTRIM]
           ,[RETE]
           ,[CODFIS]
           ,[NOME]
           ,[COGNOME]
           ,[DTNASCI]
           ,[INDIRIZZO]
           ,[CAP]
           ,[CITTA]
           ,[PROVINCIA]
           ,[NAZIONE]
           ,[CODPROF]
           ,[DTINVAL]
           ,[CODMAN]
           ,[CLASSERC]
           ,[COD_PROFEC]
           ,[FLAGPG]
           ,[CLCOMPL]
           ,[FLGCONC]
           ,[FLAGNQP]
           ,[FLGPRLRDE]
           ,[FLGPROF]
           ,[DTFINVAL]
           ,[CONCEMI]
           ,[FREQ]
           ,[LLIQUID]
           ,[PREFSOST]
           ,[FLAGAMB]
           ,[FLAGSOC]
           ,[FLAGGOV]
           ,[ADEGCONC_VALUT]
           ,[SOGLIAESG]
           ,[COERENZA]
           ,[RISERVA]
           ,[INVL_PERIOD]
           ,[MAXCOMPL]
           ,[NOCOMPL]
           ,[SPESA_FORZATA]
           ,[PERC_ILP]
           ,[IMP_RISERVA])
SELECT [DTTRIM]
      ,[RETE]
      ,[CODFIS]
      ,[NOME]
      ,[COGNOME]
      ,[DTNASCI]
      ,[INDIRIZZO]
      ,[CAP]
      ,[CITTA]
      ,[PROVINCIA]
      ,[NAZIONE]
      ,[CODPROF]
      ,[DTINVAL]
      ,[CODMAN]
      ,[CLASSERC]
      ,[CODPROFEC]
      ,[FLAGPG]
      ,[CLCOMPL]
      ,[FLGCONC]
      ,[FLAGNQP]
      ,[FLGPRLRDE]
      ,[FLGPROF]
      ,[DTFINVAL]
      ,[CONCEMI]
      ,[FREQ]
      ,[LLIQUID]
      ,[PREFSOST]
      ,[FLAGAMB]
      ,[FLAGSOC]
      ,[FLAGGOV]
      ,[ADEGCONC_VALUT]
      ,[SOGLIAESG]
      ,[COERENZA]
      ,[RISERVA]
      ,[INVL_PERIOD]
      ,[MAXCOMPL]
      ,[NOCOMPL]
      ,[SPESA_FORZATA]
      ,[PERC_ILP]
      ,[IMP_RISERVA]
  FROM FSEI0.FSEI0.[fsei0_pdc].[wseian]
  exec [C6StagingPeriodico].[RP_W6LogBatch] 'Replica WSEIAN2'
END