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?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • 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?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • I know nothing of JSON, but this looks like it is doingwhat you are trying to do

    https://docs.microsoft.com/en-us/sql/t-sql/functions/json-modify-transact-sql?view=sql-server-ver15

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

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