﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
-- [C6MartPeriodico].[PL_S36ProfiloRischio] 'F','GRNNTN55B07I158D'
CREATE procedure [C6MartPeriodico].[PL_S36ProfiloRischio] 
	-- Add the parameters for the stored procedure here
	@Rete char(1), 
	@CodiceFiscale varchar(16)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SELECT 
		MIFID.PROFILO_ASS AS codiceProfilo,
		PROFILIDIRISCHIO.NOMEPROFILO as nomeProfilo,
		DBO.TOSHORTDATESTRING(MIFID.DATA_INIZIO_VAL) AS dataInizioValidita,
		CODIFICA_RISCHIO.MAX_VAR as varMassimo
	FROM
		C6MARTPERIODICO.MIFID AS MIFID 
		INNER JOIN C6MARTPERIODICO.CODIFICA_RISCHIO AS CODIFICA_RISCHIO 
			ON MIFID.PROFILO_ASS = CODIFICA_RISCHIO.PROFILO
		INNER JOIN DBO.ProfiliDiRischio_preMUA AS PROFILIDIRISCHIO 
			ON PROFILIDIRISCHIO.CODICEPROFILO = CODIFICA_RISCHIO.PROFILO
	WHERE 1 = 1
		AND MIFID.RETE = @Rete 
		AND	MIFID.COD_FISCALE = @CodiceFiscale
END