title: SQL 'stuff' and 'FOR XML PATH' generating strange symbols
body: <p>I have the following query inside a larger Select statement in SQL Server:</p>
  
  <pre><code> CONVERT(NVARCHAR(2000),stuff((SELECT '; ' + IsNull(D2.SelectedComments,'')
   FROM #StudentDetails D2
   WHERE D2.STUD_PK = A.STUD_PK AND D2.CourseNo = A.CourseNo
  AND D2.Section = A.Section
  FOR XML PATH('')),1,2,'')) AS SelectedComments,
  </code></pre>
  
  <p>This column is generating some strange symbols after certain entries such as <code>This approach is satisfactory .&amp;#x0D</code>. I don't understand where the <code>.&amp;#x0D</code> is coming from. I tried doing <code>SELECT SelectedComments FROM #StudentDetails</code> right before this and I don't see the <code>.&amp;#x0D</code>. Can anyone tell where it could be coming from?</p>