﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <20141008>
-- Description:	<Description,,>
-- =============================================
CREATE procedure [dbo].[CREA_CAMPIONE_20160414]
	-- Add the parameters for the stored procedure here
AS
BEGIN
---------------------------------------------------------------
--SELEZIONE DEI PRIMI 200 CLIENTI ORDINATI PER NUMERO DI CASI-- 
---------------------------------------------------------------
select distinct campione.*
into #appoCamp1
from (
select b.*
FROM [C6MartPeriodico].[selezionecampione2] A
inner join (
SELECT d.*,
([c1]+[c2]+[c3]+[c4]+[c5]+[c6]+[c7]+[c8]+[c9]+[c10]+[c11]+[c12]+[c13]+[c14]+[c15]+[c16]+[c17]+[c18]+[c19]+[c20]
+[c21]+[c22]+[c23]+[c24]+[c25]+[c26]+[c27]+[c28]+[c29]+[c30]+[c31]+[c32]+[c33]+[c34]+[c35]+[c36]+[c37]+[c38]+[c39]+[c40]
+[c41]+[c42]+[c43]+[c44]+[c45]+[c46]+[c47]+[c48]+[c49]+[c50]+[c51]+[c52]+[c53]+[c54]+[c55]+[c56]+[c57]+[c58] 
) tot  FROM [C6MartPeriodico].[selezionecampione2] d
   )  B
  on a.rete=b.rete and a.cod_fiscale=b.cod_fiscale 
--  where c2 > 0
 ) campione 
select distinct campione.*
into #appoCamp2
from #appoCamp1 campione
  inner join 
(
select rete,cod_fiscale
from consevo_periodico.ConsulenzaEvoluta.dbo.MonitoraggioStorico s
inner join   c6stagingperiodico.appo_contratti a
on a.chiaveclientepb=s.chiaveclientePB
and datediff(dd,dtAvvio,dtsalvataggio) =0 )  diffdate
on campione.rete=diffdate.rete and campione.cod_fiscale=diffdate.cod_fiscale
select d.rete,d.cod_fiscale,id_area,nome_progetto,max(data_cono) dt
into #appoggio
from C6MartPeriodico.CONO_PIANIFICAZIONE d
where d.cod_fiscale in (
select d.cod_fiscale from #appoCamp2) -- dbo.campionetrimestrale - appocampionereport
group by d.rete,cod_fiscale,id_area,nome_progetto
select a.*
into #appoCamp3
from #appoCamp2 a
left join 
(select rete,cod_fiscale,dt
from #appoggio
where dt < '20140930') e
on a.rete=e.rete and a.cod_fiscale=e.cod_fiscale
where e.rete is null
order by tot desc
-- luca 19/1/2016
truncate table appocampionereport
-- fine luca 19/1/2016
insert into appocampionereport
select top 175
--DISASTERISCARE PER "INSERT SELECT" ed ASTERISCARE PER "SELECT"
a.rete,a.cod_fiscale,'',b.tip_contratto
--DISASTERISCARE PER "SELECT" ed ASTERISCARE PER "INSERT SELECT"
--case when b.tip_contratto=0 then 'OLD'
--     when b.tip_contratto=1 then 'AFFLUENT'
--     when b.tip_contratto=2 then 'PRIVATE'
--end as TipoContratto,
--a.*
from #appoCamp3 a
inner join C6MARTPERIODICO.CONTRATTOSEI b on a.rete=b.rete and a.cod_fiscale=b.cod_fiscale
where a.rete+a.cod_fiscale not in (select rete+cod_fiscale from c6martperiodico.test_quality)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from dbo.disallineati2)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_PROFILO_SCADUTO)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_RFA_ZERO)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MARTPERIODICO.CONTROLLO_TRIMESTRALE
where stato_report = 23)
order by tot desc
insert into appocampionereport
select top 1
--DISASTERISCARE PER "INSERT SELECT" ed ASTERISCARE PER "SELECT"
a.rete,a.cod_fiscale,'',b.tip_contratto
--DISASTERISCARE PER "SELECT" ed ASTERISCARE PER "INSERT SELECT"
--case when b.tip_contratto=0 then 'OLD'
--     when b.tip_contratto=1 then 'AFFLUENT'
--     when b.tip_contratto=2 then 'PRIVATE'
--end as TipoContratto,
--a.*
from #appoCamp3 a
inner join C6MARTPERIODICO.CONTRATTOSEI b on a.rete=b.rete and a.cod_fiscale=b.cod_fiscale
where a.rete+a.cod_fiscale not in (select rete+cod_fiscale from c6martperiodico.test_quality)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from dbo.disallineati2)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_PROFILO_SCADUTO)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_RFA_ZERO)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MARTPERIODICO.CONTROLLO_TRIMESTRALE
where stato_report = 23)
and c6 > 0
order by b.tip_contratto desc, tot desc
insert into appocampionereport
select top 1
--DISASTERISCARE PER "INSERT SELECT" ed ASTERISCARE PER "SELECT"
a.rete,a.cod_fiscale,'',b.tip_contratto
--DISASTERISCARE PER "SELECT" ed ASTERISCARE PER "INSERT SELECT"
--case when b.tip_contratto=0 then 'OLD'
--     when b.tip_contratto=1 then 'AFFLUENT'
--     when b.tip_contratto=2 then 'PRIVATE'
--end as TipoContratto,
--a.*
from #appoCamp3 a
inner join C6MARTPERIODICO.CONTRATTOSEI b on a.rete=b.rete and a.cod_fiscale=b.cod_fiscale
where a.rete+a.cod_fiscale not in (select rete+cod_fiscale from c6martperiodico.test_quality)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from dbo.disallineati2)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_PROFILO_SCADUTO)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_RFA_ZERO)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MARTPERIODICO.CONTROLLO_TRIMESTRALE
where stato_report = 23)
and c16 > 0
order by b.tip_contratto desc, tot desc
insert into appocampionereport
select top 1
--DISASTERISCARE PER "INSERT SELECT" ed ASTERISCARE PER "SELECT"
a.rete,a.cod_fiscale,'',b.tip_contratto
--DISASTERISCARE PER "SELECT" ed ASTERISCARE PER "INSERT SELECT"
--case when b.tip_contratto=0 then 'OLD'
--     when b.tip_contratto=1 then 'AFFLUENT'
--     when b.tip_contratto=2 then 'PRIVATE'
--end as TipoContratto,
--a.*
from #appoCamp3 a
inner join C6MARTPERIODICO.CONTRATTOSEI b on a.rete=b.rete and a.cod_fiscale=b.cod_fiscale
where a.rete+a.cod_fiscale not in (select rete+cod_fiscale from c6martperiodico.test_quality)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from dbo.disallineati2)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_PROFILO_SCADUTO)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_RFA_ZERO)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MARTPERIODICO.CONTROLLO_TRIMESTRALE
where stato_report = 23)
and c42 > 0
order by b.tip_contratto desc, tot desc
------------------------------------------------------------------------------LUCA
--insert into appocampionereport
--select top 1
----DISASTERISCARE PER "INSERT SELECT" ed ASTERISCARE PER "SELECT"
--a.rete,a.cod_fiscale,'',b.tip_contratto
----DISASTERISCARE PER "SELECT" ed ASTERISCARE PER "INSERT SELECT"
----case when b.tip_contratto=0 then 'OLD'
----     when b.tip_contratto=1 then 'AFFLUENT'
----     when b.tip_contratto=2 then 'PRIVATE'
----end as TipoContratto,
----a.*
--from #appoCamp3 a
--inner join C6MARTPERIODICO.CONTRATTOSEI b on a.rete=b.rete and a.cod_fiscale=b.cod_fiscale
--where a.rete+a.cod_fiscale not in (select rete+cod_fiscale from c6martperiodico.test_quality)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from dbo.disallineati2)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_PROFILO_SCADUTO)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_RFA_ZERO)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MARTPERIODICO.CONTROLLO_TRIMESTRALE
--where stato_report = 23)
--and c39 > 0
--order by b.tip_contratto desc, tot desc
--insert into appocampionereport
--select top 1
----DISASTERISCARE PER "INSERT SELECT" ed ASTERISCARE PER "SELECT"
--a.rete,a.cod_fiscale,'',b.tip_contratto
----DISASTERISCARE PER "SELECT" ed ASTERISCARE PER "INSERT SELECT"
----case when b.tip_contratto=0 then 'OLD'
----     when b.tip_contratto=1 then 'AFFLUENT'
----     when b.tip_contratto=2 then 'PRIVATE'
----end as TipoContratto,
----a.*
--from #appoCamp3 a
--inner join C6MARTPERIODICO.CONTRATTOSEI b on a.rete=b.rete and a.cod_fiscale=b.cod_fiscale
--where a.rete+a.cod_fiscale not in (select rete+cod_fiscale from c6martperiodico.test_quality)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from dbo.disallineati2)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_PROFILO_SCADUTO)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_RFA_ZERO)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MARTPERIODICO.CONTROLLO_TRIMESTRALE
--where stato_report = 23)
--and c45 > 0
--order by b.tip_contratto desc, tot desc
--insert into appocampionereport
--select top 1
----DISASTERISCARE PER "INSERT SELECT" ed ASTERISCARE PER "SELECT"
--a.rete,a.cod_fiscale,'',b.tip_contratto
----DISASTERISCARE PER "SELECT" ed ASTERISCARE PER "INSERT SELECT"
----case when b.tip_contratto=0 then 'OLD'
----     when b.tip_contratto=1 then 'AFFLUENT'
----     when b.tip_contratto=2 then 'PRIVATE'
----end as TipoContratto,
----a.*
--from #appoCamp3 a
--inner join C6MARTPERIODICO.CONTRATTOSEI b on a.rete=b.rete and a.cod_fiscale=b.cod_fiscale
--where a.rete+a.cod_fiscale not in (select rete+cod_fiscale from c6martperiodico.test_quality)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from dbo.disallineati2)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_PROFILO_SCADUTO)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_RFA_ZERO)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MARTPERIODICO.CONTROLLO_TRIMESTRALE
--where stato_report = 23)
--and c56 > 0
--order by b.tip_contratto desc, tot desc
--insert into appocampionereport
--select top 1
----DISASTERISCARE PER "INSERT SELECT" ed ASTERISCARE PER "SELECT"
--a.rete,a.cod_fiscale,'',b.tip_contratto
----DISASTERISCARE PER "SELECT" ed ASTERISCARE PER "INSERT SELECT"
----case when b.tip_contratto=0 then 'OLD'
----     when b.tip_contratto=1 then 'AFFLUENT'
----     when b.tip_contratto=2 then 'PRIVATE'
----end as TipoContratto,
----a.*
--from #appoCamp3 a
--inner join C6MARTPERIODICO.CONTRATTOSEI b on a.rete=b.rete and a.cod_fiscale=b.cod_fiscale
--where a.rete+a.cod_fiscale not in (select rete+cod_fiscale from c6martperiodico.test_quality)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from dbo.disallineati2)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_PROFILO_SCADUTO)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_RFA_ZERO)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MARTPERIODICO.CONTROLLO_TRIMESTRALE
--where stato_report = 23)
--and c57 > 0
--order by b.tip_contratto desc, tot desc
--insert into appocampionereport
--select top 1
----DISASTERISCARE PER "INSERT SELECT" ed ASTERISCARE PER "SELECT"
--a.rete,a.cod_fiscale,'',b.tip_contratto
----DISASTERISCARE PER "SELECT" ed ASTERISCARE PER "INSERT SELECT"
----case when b.tip_contratto=0 then 'OLD'
----     when b.tip_contratto=1 then 'AFFLUENT'
----     when b.tip_contratto=2 then 'PRIVATE'
----end as TipoContratto,
----a.*
--from #appoCamp3 a
--inner join C6MARTPERIODICO.CONTRATTOSEI b on a.rete=b.rete and a.cod_fiscale=b.cod_fiscale
--where a.rete+a.cod_fiscale not in (select rete+cod_fiscale from c6martperiodico.test_quality)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from dbo.disallineati2)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_PROFILO_SCADUTO)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_RFA_ZERO)
--and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MARTPERIODICO.CONTROLLO_TRIMESTRALE
--where stato_report = 23)
--and c58 > 0
--order by b.tip_contratto desc, tot desc
--------------------------------------- FINE LUCA
insert into appocampionereport
select 
--DISASTERISCARE PER "INSERT SELECT" ed ASTERISCARE PER "SELECT"
a.rete,a.cod_fiscale,'',b.tip_contratto
--DISASTERISCARE PER "SELECT" ed ASTERISCARE PER "INSERT SELECT"
--case when b.tip_contratto=0 then 'OLD'
--     when b.tip_contratto=1 then 'AFFLUENT'
--     when b.tip_contratto=2 then 'PRIVATE'
--end as TipoContratto,
--a.*
from #appoCamp3 a
inner join C6MARTPERIODICO.CONTRATTOSEI b on a.rete=b.rete and a.cod_fiscale=b.cod_fiscale
where a.rete+a.cod_fiscale not in (select rete+cod_fiscale from c6martperiodico.test_quality)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from dbo.disallineati2)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_PROFILO_SCADUTO)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MartPeriodico.CONTROLLO_TRIMESTRALE_RFA_ZERO)
and   a.rete+a.cod_fiscale not in (select rete+cod_fiscale from C6MARTPERIODICO.CONTROLLO_TRIMESTRALE
where stato_report = 23)
and   a.rete+a.cod_fiscale in
-- RACCOMANDATE
	('FTGLMRA30A04A409N'
	,'FBZZGPP46C18A409M'
	,'FCCRGPP54B27H307C'
	,'FCRNCST86C56G062N'
	,'FGHNDNL46L21G007R'
	,'FGNSMNL58D47H037E'
	,'FNAIGNE40H10B463Q'
	,'FNCLLCU74M70L682S'
	,'FPRNNTN32B06E003M'
	,'FPRTNMR29R62L219X' --co non più attivo
	,'FRLDLCN35B18A409N'
	,'FRPILNI47M11L746H'
	,'FSNEPMR60S24I976R'
	,'FTBRFRZ68L20H037P'
	,'FTBRGBR37R22G062P'
	,'FTBRMRZ65H27H037W'
	,'FTTTGDE24D04A409P' -- co non più attivo
	,'FBRLGCR25P13B885H'
	,'FMRNNZE22A01F205W' -- profilo scaduto
	,'FMRNGMR53P60F205P'
-- 250 casi test individuati da Scirocco-Quaranta
,'SBBALDA42L69C660I',
'FBCCFNC30H12L219Y',
'FBFFNGL37D19D245V',
'FBGLCRD41B61F205K',
'FBGZGNN40M45D612G',
'FBLLLGU46L21A191N',
'FBNGMLL33C49A794A',
'SBNOLGU65H28E290R',
'SBRGNRC63L01L219L',
'FBAAMTR48C43I470Y',
'FBAEMJA43E70Z133C',
'SBBBLGO28A43F637C',
'FBCCDCE46S22I068J',
'FBRZLVR50S44F965F',
'FCCOMNL48P22A056F',
'FCHRLBT33H58L219J',
'FCLMGNZ58E02M147X',
'FCRTLRD44A17A246K',
'SCVCRTI69D68G643C',
'SCZZNNP52R69D969U',
'SDGHCLD59T30L304C',
'FDRSGPP62S55A512W',
'SDSDGRZ52M46G628J',
'FDSMPLG48D30B424N',
'SFBBBBR69D42Z133D',
'SFBNNZE58B58A089T',
'SFVRFRZ63L10L840J',
'SGTAMDR50M71C415E',
'SJCCGRG38T27A326Q',
'SJCPGFR42E03G224H',
'SLVRDLA25S47B157C',
'FBFFNGL40C07A191T',
'SMRTFRL70D17Z114U',
'SNCLCRL76E10H501X',
'FBGODNL68R47H294D',
'SBLDMTN83R42L746N',
'FBLGVLI42D59G747R',
'FPGLCRL55S04F158Y',
'SPGLVCN44C50F817O',
'SPLTCLD48T07L753V',
'FPRVNNL54D46A794W',
'FRNCNDR88B16A475F',
'FRVSDGN37D67F133B',
'FSCCFNC51T07L030D',
'FSCGLRA60S53L736D',
'STLICCT55D19C351B',
'FVLNLVI62R29F398C',
'FZPTCST86P30Z604K',
'FBLLRLD34B06G664X',
'SBNDSNE47R62A040Z',
'FBNNNLI66A49E715K',
'SCCCSDR59E28E472B',
'FCRTGPP56M65F304H',
'SCVDMNG50E49D482N',
'SDBNFNC38L24D969G',
'SDFBPLA70L28H501P',
'FDLMGPR21H24F205P',
'FDLMLCU63R03E289N',
'FDMSLRS44E06D609O',
'SDSCPRZ60M61F952X',
'SDZZLVI61P18L219F',
'FFBBFNC35T50A944D',
'FFBBSVC40R53A851T',
'FFCCFDL48D10F242K',
'SFNTMRA47A11H501U',
'FFRNNGL61R17D704E',
'SFTTMRM60B53F508M',
'SFZZNNA46E52B293U',
'SGAINRC35L25D969J',
'SGBRGLC70L03F257S',
'FGBRGRL41L68H501E',
'FGBRGRL53L14H714J',
'FGVNNDR72S20E463X',
'SLZTPCR47S29A017U',
'FMZZSFN68D05E507F',
'FNBBFNC33T13H223X',
'SNCLFNC61R29G482Y',
'FNSLGRG70L06H727L',
'FNZLPRZ67L44C743K',
'FPTRLLN49A43A633J',
'FPVSRCR72L01A794D',
'FQRTVNN55S10G337A',
'FRNDGNN60M57D458C',
'FSCGLFA40B04G467F',
'SSVNSVN61R15L295O',
'FVDNMRN54A53L682F',
'FVLLFRC78E26F965G',
'FVLTLSN69P45A794U',
'SZLOGFR66L05G031Z',
'SFRZMHL63S11A182H',
'FNDRGFR46H28H816G',
'FGSPCMN24R50G535X',
'FLCTCLB52B22B910V',
'FPRSNLG48A06I452L',
'FFTTRRT64E70H501Q',
'FMRLSLV60A50H223V',
'FFBNCHR75T71C765V',
'SGZZMLV44P59B328P',
'FCCHPCD37P25F654J',
'FPRCLTT53S46E837D',
'FBFFNCL34L57C712F',
'FLCSZEI61L20L219R',
'FGHTMNC62H54L219A',
'FCRTGPP51A68G062O',
'FCMNDNT55C56A944A',
'FGRBLCU78B63E388O',
'FBAANGL45S03E472U',
'FQZECML41P21M021X',
'FVGLFRC84S68L219D',
'FRAICLM62B41A124Z',
'FBLLLGU33M17H598Z',
'FPNZRND47R08H361M',
'FMRLPTR37B27G179W',
'FPRZLNE38S60F717W',
'FBFFNDR60S25H501N',
'FCRTLRD33T19E094X',
'SFNTMRA42C49L781H',
'FBAUMLS47R69F864K',
'FGGLLDI36B42I622Z',
'FBAILDI62S56A794Z',
'FBMBLRF90E50L219G',
'FCMLNRT52L48G157B',
'FCCOLFA50P30A056F',
'FCRNNTN34L12F839V',
'SDBBTMS21A01E885K',
'SBBBNTN59M25H725F',
'SLMNMGR56E46D653B',
'SCFFFPP66D18D969P',
'SFSCGPP45C07L259I',
'SKSRGRD59S24F839I',
'SBZZPTR32S23I573D',
'SBBBFVN61S20F952S',
'SBBALDA40E13G684G',
'SVNTFBA69P29H501I',
'SBGGPLA66P62E463X',
'STLLMRA55P45C474K',
'SCNIBNR28M29G702B',
'SGAIRCE76T49A182F',
'SBNOMGR58L49L741U',
'SKPJVDM70H06Z100X',
'SFVLGNT55B19G742Z',
'SSPGTRS50P66F839Q',
'SMRZCLL53B45A794N',
'SMRZMNC59P68A794V',
'SBSTSLV59R51F952Q',
'SFLSLBT64C65H501Z',
'SCCCRSO46S64H501N',
'SDDMSNO47S45B433P',
'SCVRPQL69M23M082N',
'SBBBMNG29D46D205W',
'SZMBDNL49E45H501D',
'FFF@4268'         ,
'S08092471005'     ,
'S92001720017'     ,
'S02111000598'     ,
'FJNNVLD16E55F348U',
'SBTNGNN49H22I726G',
'SBRLMNG54M42C014M',
'SFRCLMP43A62C478K',
'FGRMMSM66H16D612I',
'S91020570114'     ,
'SVLPMRA43E01I287Z',
'SDLLCRL68C03H294E',
'SFLRVGL48D26F979S',
'SBBDFNC28A19E602R',
'FFF@8715'         ,
'SMSTMRS55S65A783N',
'SPLLGRL41C22E463N',
'SNCCMFR51E42H468M',
'SBBBNLR59H11H501R',
'SBRTRLD43P21H449J',
'SPRTRST58T53L219L',
'SBBNGCR56R59F817O',
'SCNGLLN50E70L245U',
'SQTTGLN57M42A269L',
'SCTCGCR41C21G920A',
'SFSCFRZ67E23G482M',
'SJCCSNT44P56H501L',
'S10733481005'     ,
'SGSPMGR31T69G482B',
'FCRNPRZ59H55E290K',
'SBRLMLR52P45G337S',
'SFRCLRT65C22E957W',
'FPLTTNM51R63F952U',
'FBBNTTN70H51Z154P',
'SDVSNMR76E49L418D',
'FCCHCLD60M09L706A',
'SBNDRMO45S22F642B',
'SZPPNGL23M70L633U',
'F80218090589'     ,
'SGGLMCN62M44F112K',
'SPSTBRN29M70G528H',
'SMSTDRN62S06H501I',
'FNFRNMR30C69C574V',
'FPCCNNL55L42B832J',
'FBAIMRC74M29L157G',
'SCAUGNN23C51H501U',
'FBLDMNC70D41C111F',
'SDFBCST94E63G878N',
'FBLLRLA69H24E463K',
'FBMBLRI84R70L219M',
'SCTTMTT78H08F205L',
'F80059170581'     ,
'FLCTFRC61L04A794V',
'SGSTDMR65R01E715S',
'FBAINTN41C04E864R',
'FDLSNRN48A01H501Y',
'FPRSMVN40D05G273R',
'F01621300597'     ,
'SGSTSRG60E01H501T',
'FBBBCLD51A17I480R',
'F97762280010'     ,
'SPLLGRT39M66Z112H',
'SMCCVTR41E09F736B',
'FFBRMLC30E50E864W',
'S01705010591'     ,
'FBCCFNC37C06D969P',
'FFMGLDI71S49I858Q',
'SCBLSLD45M08H501C',
'S07735910585'     ,
'FBAASFN72B19E472H',
'F97665800153'     ,
'FBAAGRL59E54I470S',
'FFMEFMN49B45E956U',
'SNGRCLD62A47Z404V',
'FCRVGNN53T57C243L',
'F00423970060'     ,
'SBLDNLT64T46A984O',
'SCSLSFN82R22F257J',
'FDTTSLV82T49H501H',
'FVCNLRA79L51B296M',
'FGHRVNT72T57A479A',
'F03387060548'     ,
'SPLNLSN38P28G401U',
'SZPPDRD57E15G493Z',
'FFLNMHL74M13I829Z',
'FDRSLSN77C25L219Y',
'FTFFCST75T45L219A',
'FGRMLSN66D57A944O',
'FDSGWND29M45C627O',
'FNSTGNN50L27F205U',
'SBBTMTL87D07G348I',
'FBBNNNI58L41F471I',
'FFRNMRZ64H08F454W',
'SGCMGLN45A63B982R',
'FBGGCST58S49D704L',
'FCHRLGU38C09E887Z',
'SDRSRSR49D70F839H',
'SSPSVCN66S01F839D',
'SBBNPML78E44A984U'
)
drop table #appoCamp1
drop table #appoCamp2
drop table #appoCamp3
truncate table C6MartPeriodico.TB_Campione
insert into  C6MartPeriodico.TB_Campione
select distinct rete, cod_fiscale, 1 --1 è il campo flag stampa che indica che dev esser stampato in fase di generazione del campione, 0 niente stampa
from appocampionereport
END