PDC_REPORT_CreazioneDB/sql/storedTestbes/C6MartPeriodico_RESTART_CONTROLLO_TRIMESTRALE.sql
2025-06-06 19:02:52 +02:00

25 lines
968 B
SQL

-- Stored procedure
CREATE procedure [C6MartPeriodico].[RESTART_CONTROLLO_TRIMESTRALE]
AS
BEGIN
INSERT INTO C6MARTPERIODICO.CONTROLLO_TRIMESTRALE
--SELECT DISTINCT COD_FISCALE, RETE, FLAG_DIAGNOSI, NULL, NULL, 1, NULL, getdate() FROM C6MARTPERIODICO.CONTROLLO_TRIMESTRALE WHERE STATO_REPORT=7
select distinct cod_Fiscale,b.rete, flag_diagnosi,null,null,1,null,getdate()
from --c6martperiodico.gestione_pdf_ftp a
--join
c6martperiodico.controllo_trimestrale b
--on a.rete=b.rete and a.codiceFiscale = b.cod_fiscale
--where id_fk_zip = 353
--and
where b.rete+b.cod_Fiscale in (select distinct rete + codiceFiscale from c6martperiodico.excludedlist where bloccato = 0)
--where bloccato = 1)
and stato_report < 20 and stato_report >= 4
END
--
--select count(*),stato_report
--from c6martperiodico.controllo_trimestrale
--group by stato_report
--
--select * from c6martperiodico.controllo_trimestrale
--where cod_fiscale = 'BBBRFL74M50C573M'
--where stato_report = 7