Create  procedure [dbo].[AMB_InfoPdfTrim] ( @CF varchar(20) = 'DMECST71D10H501E') as   
BEGIN  
  Declare @dtTrime numeric = (select MAX(dttrim) from c6stagingPeriodico.wseips)
  Select 'PERIMETRO' APPO_CONTRATTI	, * From  C6StagingPeriodico.APPO_CONTRATTI				where Cod_Fiscale = @CF   
  Select 'FTP' GESTIONE_PDF_FTP			, * From  C6MartPeriodico.GESTIONE_PDF_FTP				where CodiceFiscale = @CF   
  Select 'FTP_HST' GESTIONE_PDF_FTP_HST		, * From  C6MartPeriodico.GESTIONE_PDF_FTP_HST			where CodiceFiscale = @CF   
  select distinct 'wseiPS' wseiPS, 'Profilo Scaduto' as DescrErr, *  from c6stagingPeriodico.wseips  where CodFis = @CF and dttrim = @dtTrime  
  select distinct 'wseiDC' wseiDC, case tipolett when  '0' then 'RFA=0' when '6' then 'RFA Minus' when '2' then 'BLACKLIST RFA MINUS CLIENTE SEI E IMMOBILIARE' when 'A' then 'Profilo EC' END AS  DescrErr, *  from c6stagingPeriodico.wseiDC  where CodFis = @CF and dttrim = @dtTrime and TIPOLETT not in ('R','S')
  Select 'ExcludedList' ExcludedList, * from [C6MartPeriodico].[ExcludedList] e where e.codicefiscale = @CF
END