SQL line feed for XML path

When I run the code below
instead of getting new clean line feed, I get  
 which seems to be an line escape for XML.
Is there a way to get around this?
DECLARE @Comment XML

SET @Comment = 
(SELECT DISTINCT RTRIM(comment1) + '' + CHAR(13) + RTRIM(comment2) + '' + CHAR(13)+ 
RTRIM(comment3) + '' + CHAR(13) + RTRIM(comment4)
FROM Comments FOR XML PATH(''))

SELECT @Comment

Open in new window

kmc10314Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lcohanDatabase AnalystCommented:
Even though the syntax is correct that is not a valid statement for xml path and you should start here: http://msdn.microsoft.com/en-us/library/ms189885.aspx

Then http://msdn.microsoft.com/en-us/library/bb510469.aspx
         http://msdn.microsoft.com/en-us/library/bb522647.aspx
Then any other link from "Using PATH Mode" that suits your needs for coding.

--for example your query should look like:
SELECT top 10
       comment1,
       comment2,
       comment3,
       comment4
FROM Comments WITH (NOLOCK)
FOR XML PATH;
GO
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kmc10314Author Commented:
it's not working.
0
lcohanDatabase AnalystCommented:
Sorry - what "it's not working"?
I can run the query I posted above in SQL 2005/2008 of course against one of my own tables that has 4 varchar(255) fields and I have no issues.
0
Anthony PerkinsCommented:
You do realize there is no concept of Cr (or Lf for that matter) in Xml, right?  All unprintable characters (such as Cr and Lf) have to be encoded using the Hex equivalent.  That is what you are seeing.  &#x0D = Cr.
0
Anthony PerkinsCommented:
>>Is there a way to get around this?<<
You will have to convert the Xml to a string and then you can add all the Cr you like.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.