sql server - SQL 'stuff' and 'FOR XML PATH' generating strange symbols -
i have following query inside larger select statement in sql server:
convert(nvarchar(2000),stuff((select '; ' + isnull(d2.selectedcomments,'') #studentdetails d2 d2.stud_pk = a.stud_pk , d2.courseno = a.courseno , d2.section = a.section xml path('')),1,2,'')) selectedcomments,
this column generating strange symbols after entries such this approach satisfactory .
. don't understand .
coming from. tried doing select selectedcomments #studentdetails
right before , don't see .
. can tell coming from?
if modify use of xml path, unescaping , won't need resort using replace function:
, stuff( ( select '; ' + isnull( d2.selectedcomments, '' ) #studentdetails d2 d2.stud_pk = a.stud_pk , d2.courseno = a.courseno , d2.section = a.section xml path(''), type ).value('.', 'nvarchar(max)') , 1, 2, '') selectedcomments
Comments
Post a Comment