CREATE procedure [C6StagingPeriodico].[ClienteProdottiAssicurativiVita]
@Rete as varchar(1),
@CodiceFiscale as varchar(16)
as
declare @tblFlagNota table
(
	FlagAssVita char(1)
)
DECLARE @conta INT
SELECT @conta = count(*)
from C6MartPeriodico.PATRIMONIO_BF bf
inner join C6STAGINGPERIODICO.RP_CATALOGOPRODOTTI KAT
on bf.COD_PRODOTTO = kat.CatalogueID
where kat.Alberatura in (7,8,9)
	AND bf.cod_fiscale = @CodiceFiscale
	AND bf.rete = @Rete
if @conta >= 1
begin 
	insert into @tblFlagNota (FlagAssVita) Values ('S')
end
else
	insert into @tblFlagNota (FlagAssVita) Values ('N')
Select FlagAssVita from @tblFlagNota