PDC_REPORT_CreazioneDB/sql/storedProduzione/C6MartPeriodico_Popola_W6ASSETPERC_20190701.sql
2025-06-06 19:02:52 +02:00

46 lines
1.5 KiB
Transact-SQL

-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE procedure [C6MartPeriodico].[Popola_W6ASSETPERC_20190626]
AS
BEGIN
SET NOCOUNT ON;
delete from [consuni].consulenzaunica.[dbo].[W6ASSETPERC]
INSERT INTO [consuni].consulenzaunica.[dbo].[W6ASSETPERC]
(
[COD_INTERNO]
,[COD_SOTTOPRODOTTO]
,[COD_ISIN]
,[COD_MAF]
,[ID_ASSETCLASS]
,[CATALOGUENAME]
,[ASSETCLASSNAME]
,[BDPERCENTAGE]
----------modifica del 24/6/2019
,[Visibilita]
----------FINE modifica del 24/6/2019
)
SELECT DISTINCT
isnull(cat.CodInterno,'') AS COD_INTERNO,
isnull(cat.CodSottoprodotto,'') AS COD_SOTTOPRODOTTO,
isnull(cat.CodIsin,'') AS COD_ISIN,
isnull(cat.CodMaf,'') AS COD_MAF,
isnull(LTRIM(RTRIM(ac.Asset)),'') AS ID_ASSETCLASS,
isnull(cat.NomeProdotto,'') as CATALOGUENAME,
isnull(ac.Descrizione,'') as ASSETCLASSNAME,
isnull(LTRIM(RTRIM(map.Percentuale)),'') AS BDPERCENTAGE,
-- ----------modifica del 24/6/2019
isnull(cat.visibilita,'') AS VISIBILITA
----------FINE modifica del 24/6/2019
FROM C6StagingPeriodico.RP_Mappatura AS map
INNER JOIN C6StagingPeriodico.RP_AssetClass AS ac
ON map.Asset = ac.Asset
INNER JOIN C6StagingPeriodico.RP_CatalogoProdotti cat
ON map.ChiaveProdotto = cat.ChiaveProdotto
WHERE Livello = 2
-- ----------modifica del 30/5/2019
and cat.CodInterno is not null
-- ----------fire modifica del 30/5/2019
END