title: Could not create the JSON-formatted Column in SQL Table with including NULL Values
body: <p>I need to combine in one Table the SQL Data with columns, formatted as JSON. The Json columns are a vary length, from 4 to 5 Columns. So I need to add one optional NULL column to the JSON String, when the Length is 4. But if I put the 4-Places Json String in my Function, I get no results</p>
  <p>What is wrong In folowing Function?</p>
  <pre><code>DECLARE @json1 nvarchar(max),
          @json2 nvarchar(max)
  
  --SET @json1 = '{&quot;Inst&quot;:[{&quot;id&quot;:-627706141,&quot;Instances&quot;:&quot;Inst22&quot;}
  --,{&quot;id&quot;:-627706141,&quot;Instances&quot;:&quot;20200605&quot;}
  --,{&quot;id&quot;:-627706141,&quot;Instances&quot;:&quot;Sometghing&quot;}
  --,{&quot;id&quot;:-627706141,&quot;Instances&quot;:&quot;SomeServer&quot;}
  --,{&quot;id&quot;:-627706141,&quot;Instances&quot;:&quot;OptionalServer&quot;}]}'
  SET @json1 = '{&quot;Inst&quot;:[{&quot;id&quot;:1505267576,&quot;Instances&quot;:&quot;Inst22&quot;}
  ,{&quot;id&quot;:1505267576,&quot;Instances&quot;:&quot;20190630&quot;}
  ,{&quot;id&quot;:1505267576,&quot;Instances&quot;:&quot;Something&quot;}
  ,{&quot;id&quot;:1505267576,&quot;Instances&quot;:&quot;SomeServer&quot;}]}'
  SET @json2 = '{&quot;Value&quot;:[{&quot;id&quot;:-627706141,&quot;Werte&quot;:&quot;Intel(R) Xeon(R) CPU E5-2690 v3 &quot;},{&quot;id&quot;:-627706141,&quot;Werte&quot;:&quot; 2.60GHz&quot;}]}'
  
  SELECT * 
  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 ``` 
  </code></pre>