kromm77 icon

[SQL_SERVER] Update Json

kromm77 | PRO | 07/12/19 11:56:19 AM UTC | 0 ⭐ | 6641 👁️ | Never ⏰ | []
T-SQL |

1.37 KB

|

None

|

0 👍

/

0 👎

with customprop as (
    SELECT  
    ea.CustomPropertiesJson,
    JSON_VALUE ( ea.CustomPropertiesJson,'$.nomeProdotto')  as nomeProdotto ,
    JSON_VALUE ( ea.CustomPropertiesJson,'$.nomeProdottoVisibileCreazioneIntervista')  as nomeProdottoVisibileCreazioneIntervista ,
    JSON_VALUE ( ea.CustomPropertiesJson,'$.id')  as idJson ,
    JSON_VALUE ( ea.CustomPropertiesJson,'$.apriFormat')  as apriFormat ,
    JSON_VALUE ( ea.CustomPropertiesJson,'$.idMaster')  as idMaster ,
    JSON_VALUE ( ea.CustomPropertiesJson,'$.idModelloDaInviare')  as idModelloDaInviare ,
    ISNUMERIC(code) is_numeric,
    --JSON_MODIFY ( ea.CustomPropertiesJson , '$.idModelloDaInviare' , CAST(code AS NUMERIC(12,0)) ) as newIdModello,
    ea.Id,
    ea.Description,
    ea.Code
    FROM [Finservice.SurveyDb.Test].[dbo].[EventArguments] as  ea) ,
    ncustomprop as (
    select id,idJson,nomeProdotto,Description,apriFormat,idMaster,idModelloDaInviare,JSON_MODIFY (  CustomPropertiesJson , '$.idModelloDaInviare' , CAST(code AS NUMERIC(12,0)) ) as newIdModello 
    from customprop 
    where is_numeric = 1 and idModelloDaInviare= -1
  )
  --select  from ncustomprop
  update  [Finservice.SurveyDb.Test].[dbo].[EventArguments]
set CustomPropertiesJson = ncustomprop.newIdModello
from   ncustomprop join [Finservice.SurveyDb.Test].[dbo].[EventArguments] on [Finservice.SurveyDb.Dev_Server].[dbo].[EventArguments].id = ncustomprop.id

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎