title: SQL Server SELECT to JSON function
body: <p>I would like to output the results of a <code>SELECT</code> statement as a JSON object.</p>
  
  <p>I would like this to be a <strong>Function</strong> and not a <strong>stored procedure</strong>!</p>
  
  <p>For example, the below table Users</p>
  
  <pre><code>id    name        active
  1     Bob Jones   1
  2     John Smith  0
  </code></pre>
  
  <p>Would be returned like this:</p>
  
  <pre><code>[{"id":1,"name":"Bob Jones","active":1},{"id":2,"name":"John Smith","active":0}]
  </code></pre>
  
  <p>Thanks in advance.</p>