JSON structure positioning

  • I have the following

     

    declare @X nvarchar(max)

    set @X='[

    {

    "a": "",

    "b": "",

    "c": "",

    "e": "",

    "f": "",

    "g": ""

    }

    ]'

    declare @y nvarchar(max)

    set @y='{"bac": ""}'

     

    what I need is

     

    '"pro": [

    {

    "a": "",

    "b": "",

    "c": "",

    "address": {

    "bac": ""

    },

    "e": "",

    "f": "",

    "g": ""

    }

    ]'

  • Hi and good morning

    Sorry but I dont know what is your goal?

    Mayby you will insert something in IT?  Then use placeholder for it.

    example: your @x variable has inside a  placeholder <<<bac>>> and <<<adress>>>.

    With replace Statement you Put in what you need.

    Set @z = replace (replace (@X,'<<<adress>>>' , @adress),'<<<bac>>>',@bac)

     

     

  • Can you explain the logic behind this requirement, please?

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • this can only be achieved using tsql json functions only

     

    I masked them , I work on medical data

  • danssms wrote:

    this can only be achieved using tsql json functions only

    I masked them , I work on medical data

    Do you believe this to be a detailed and thorough response to my question?

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply