-- Schema: dbo
-- Stored Procedure: CONTROLLO_COMPLESSITA


CREATE procedure [dbo].[CONTROLLO_COMPLESSITA]

as

begin

declare @cf as varchar(16)
set @cf = 'CSRRNZ50R55I802I'


SELECT max(a.complex) as complexMaxInPTF
FROM C6STAGINGPERIODICO.CATITEMREF A INNER JOIN 
C6MARTPERIODICO.PATRIMONIO_Bf B
ON A.CATALOGUEID = SUBSTRING(B.POSITION_ID,1,57) 
WHERE B.COD_FISCALE=@cf


SELECT max(a.complex) as complexMaxInPTFGiorn
FROM C6STAGING.CATITEMREF A INNER JOIN 
C6MARTPERIODICO.PATRIMONIO_Bf B
ON A.CATALOGUEID = SUBSTRING(B.POSITION_ID,1,57) 
WHERE B.COD_FISCALE=@cf

SELECT cod_profec as complexProfiloCliente
FROM C6STAGINGPERIODICO.wSEIAN2
WHERE CODFIS=@cf
AND DTTRIM =20110930



SELECT *
FROM C6STAGINGPERIODICO.CATITEMREF A INNER JOIN 
C6MARTPERIODICO.PATRIMONIO_Bf B
ON A.CATALOGUEID = SUBSTRING(B.POSITION_ID,1,57) 
WHERE B.COD_FISCALE=@cf


SELECT *
FROM C6STAGING.CATITEMREF A INNER JOIN 
C6MARTPERIODICO.PATRIMONIO_Bf B
ON A.CATALOGUEID = SUBSTRING(B.POSITION_ID,1,57) 
WHERE B.COD_FISCALE=@cf

end


