--select * from [C6StagingPeriodico].[WSEIAN2] where cod_profec is null
--select * from [C6StagingPeriodico].[WSEIDC]
--select * from [C6StagingPeriodico].[WSEIPS]
--select * from [C6StampeCentralizzate].[C6MartPeriodico].[tabellone] where flgprof='s' and cfm_tipo_consul='retail'
CREATE procedure [C6StagingPeriodico].[immobiliare_tabellone]
	as
	begin
		UPDATE [C6StampeCentralizzate].[C6MartPeriodico].[tabellone]
	set flgpe_perimetro_semestr=i.FLAG_IN_PERIMETRO,solo_rend_imm=isnull(i.RENDICONTO_IMM,'N'),anche_rend_sei=i.RENDICONTO_SEI
	from [C6StampeCentralizzate].[C6MartPeriodico].[tabellone] t inner join [C6MartPeriodicoImmobiliare].[W6IMM] i on i.RETE+i.CODFIS=t.chiave_acn
	truncate table C6MartPeriodico.APPREND_DTSX_Tabellone 
insert into C6MartPeriodico.APPREND_DTSX_Tabellone 
select * from C6MartPeriodico.vTabellone
end