title: Parse Json in SQL Server
body: <p>In my table, the <code>value</code> column contains json data. I am using <code>parsejson</code> to parse these values. I am using older version of SQL Server. So I am using parsejson:</p>
  
  <pre><code>id      fieldid      value
  --------------------------------------------------------------------
  1       70297        {"value":"Billable  ","text":"Billable"}
  2       70297        [{"value":"billable","text":"Billable"}]
  3       70297        [{"value":"billable","text":"Billable"},
                       {"value":"nonbillable","text":"NonBillable"}]
  4       70297        [{"value":"     nonbillable","text":"      NonBillable"}]
  </code></pre>
  
  <p>I need this output:</p>
  
  <pre><code>count   stringvalue
  --------------------
   3      Billable
   2      nonbillable
  </code></pre>
  
  <p>I am using this query to parse above json values from the table:</p>
  
  <pre><code>DECLARE @Names VARCHAR(8000) 
  
  SELECT @Names = COALESCE(@Names + ', ', '') + Value 
  FROM ValueBindings  
  WHERE fieldid = 70297
  
  SELECT COUNT(*), StringValue 
  FROM parseJSON(@Names) 
  WHERE NAME IN ('value', 'text')  
  GROUP BY StringValue
  
  SELECT @Names
  </code></pre>
  
  <p>It is not returning the expected values correctly</p>