title: How to store JSON Array as String
body: <p>I need the Function to concatenate two JSON Strings together and to insert it into one Table Column. But I do something wrong. Could You help me please?</p>
  <pre><code>create function Jsom_Merge
  (
  @json1 nvarchar(max),
  @json2 nvarchar(max)
  )
  returns nvarchar(max)
  as
  begin
  
  declare     @json3 nvarchar(max)
  
  select @json3 =
  FROM 
   (
      SELECT 
      FROM OPENJSON( @json1 )
      WITH
      ( IID sys.int '$.Inst[0].id',
          sidInstance           sys.NVARCHAR( 50 ) '$.Inst[1].Instances',
          DatumInstance         sys.NVARCHAR( 50 ) '$.Inst[2].Instances',
          ServerInstance        sys.NVARCHAR( 50 ) '$.Inst[3].Instances',
          VirtualServerInstance sys.NVARCHAR( 50 ) '$.Inst[4].Instances',
          OptionalInstance      sys.NVARCHAR( 50 ) '$.Inst[5].Instances'
      ) a
  inner join 
     OPENJSON( @json2 )
      WITH
      ( WID sys.int '$.Value[0].id',
          CPUType               sys.NVARCHAR( 50 ) '$.Value[0].Werte',
          Frequency             sys.NVARCHAR( 50 ) '$.Value[1].Werte'
      ) b on a.IID = b.WID
  ) t FOR JSON PATH , INCLUDE_NULL_VALUES
  
  return @json3
  
  end;
  </code></pre>