CREATE procedure [C6MartPeriodico].[GESTIONE_INSERT_PDF_FTP_GET_ID] 
(
	@Rete char(1), 
	@CodiceFiscale varchar(16),
	@TipoReport varchar(1)
)
AS  
BEGIN  
if exists ( select 1 from C6MartPeriodico.GESTIONE_PDF_FTP
	   where rete=@Rete and  codicefiscale=@CodiceFiscale
	   and tiporeport=@TipoReport)
	   select top(1) IdReport
	   from C6MartPeriodico.GESTIONE_PDF_FTP
	   where rete=@Rete and  codicefiscale=@CodiceFiscale
	   and tiporeport=@TipoReport
	   else
	   select -1
END