i have some data in my table
when i select that data with this query
select TblActionHistories.Comments from TblActionHistories WHERE TblActionHistories.Entity=CAST('Task' AS VARCHAR) AND EntityId=CAST(32 AS VARCHAR)
it’s coming fine like this
Task- <b>T1</b> has been added by Swapnil Sharma
Task- <b>T1</b> status changed to <b>In Progress</b> by Swapnil Sharma<br/>
but now i want my above result # separated using stuff so i am using this
SELECT STUFF((SELECT '#' + ISNULL(CAST(TblActionHistories.Comments AS VARCHAR(MAX)),'') FROM TblActionHistories WHERE TblActionHistories.Entity=CAST('Task' AS VARCHAR) AND EntityId=CAST(32 AS VARCHAR) for xml path ('')),1,1,'')
it gives me this
Task- <b>T1</b> has been added by Swapnil Sharma#Task- <b>T1</b> status changed to <b>In Progress</b> by Swapnil Sharma<br/>
you can clearly see that all the special char. like < > converted to < > respectively
please help me out with this i want them to come in their original format
well i found the solution as suggested by IvanG
ref. to this article
http://blogs.lobsterpot.com.au/2010/04/15/handling-special-characters-with-for-xml-path/