title: SQL Server : creating Json column
body: <p>I would like to create a column that contains JSON with fields calculated based on another table columns. Of course, I can make that as below but that works fine only if the case is quite simple, and still, it is easy to make mistake. Is it a more convenient way to build JSON inside of query?</p>
  <pre><code>SELECT 
      1 AS id, 'AAA' AS ProductCode, 
      'Camera' AS Product, 5000 AS Price 
  INTO
      #tmp
  UNION
  SELECT 
      2 AS id, 'BBB' AS ProductCode, 
      'Tripod ' AS Product, 80 AS Price
  UNION
  SELECT 
      3 AS id, 'CCC' AS ProductCode, 
      'Objective ' AS Product, 7000 AS Price
  
   
  SELECT 
      ProductCode,
      '{' +  '&quot;Product&quot;:&quot;' + Product + '&quot;' + ', '
          +  '&quot;Price&quot;:&quot;' + cast (Price as nvarchar) 
          +  '&quot;}' AS Details     
  FROM  
      #tmp
  </code></pre>