title: Returning comma separated values in SQL Server in one element
body: <p>I have the below query which I am using to return comma separated result.</p>
  
  <pre><code>SELECT STUFF
  (
      (
          SELECT ',' + em.EMAIL 
          FROM(
              SELECT  DISTINCT USR.EMAIL AS EMAIL
            FROM PRNCPLS A, PRNCPLS B, USER_INFO USR,
            RELATIONSHIPS C
            WHERE A.ID = C.PARENTID 
            AND B.ID = C.CHILDID
            AND A.TYPE = 'USER' and B.TYPE = 'ROLE'
            AND A.ID = USR.ID
            and B.NAME = 'Approver'
            AND USR.EMAIL IS NOT NULL) em
          ORDER BY em.EMAIL FOR XML PATH('')
      ),
       1, 1, ''
  ) AS Output
  </code></pre>
  
  <p>I have a requirement to update this query in a way that the first line of the SQL statement (and not the output) always start like this</p>
  
  <p><code>SELECT EMAIL FROM</code></p>
  
  <p>This is required since the tool I am using for some reason expects <code>FROM</code> in the first line and just one single element in the <code>SELECT</code> clause. My query actually only returns one element, so I was hoping to somehow update it.</p>
  
  <p>Expected output - abcd@gmail.com,1234@yahoo.com,xyz@gmail.com</p>
  
  <p>Any help would be appreciated.</p>