title: Join query result to a single line of values separated by comma
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2046037/sql-server-can-i-comma-delimit-multiple-rows-into-one-column">SQL Server: Can I Comma Delimit Multiple Rows Into One Column?</a>  </p>
  </blockquote>
  
  
  
  <p>I have a query like this:</p>
  
  <pre><code>SELECT name from users
  </code></pre>
  
  <p>and it's result is a number of records:</p>
  
  <pre><code>1 user1
  2 user2
  3 user3
  </code></pre>
  
  <p>I want to get all this records in a single line separated by comma:</p>
  
  <pre><code>user1, user2, user3
  </code></pre>
  
  <p>and an empty line if query result is empty.</p>
  
  <p>How to get this using <code>T-SQL</code>? <code>UNPIVOT</code>?</p>