Click here to Skip to main content
15,905,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using stuff in sql to concat text data, but when i use stuff it convert symbol to its code.

In source records are like below.

<NONE> to BC


but when i use stuff for it, it return me like this as below.

<NONE> to BC


What I have tried:

I use stuff like this
 stuff((Select ' '+ nt.TextLine
From [table1]
FOR xml path('')),1,1,'')
Posted
Updated 6-Oct-21 21:54pm

1 solution

Try:
SQL
STUFF((SELECT ' ' + TextLine FROM [table1] FOR XML PATH(''), TYPE).value('.', 'varchar(max)'), 1, 1, '')
See "The blackbox XML methods" section in this article for details:
Concatenating Row Values in Transact-SQL - Simple Talk[^]

NB: If you're using SQL Server 2017 or later, you could use STRING_AGG instead:
STRING_AGG (Transact-SQL) - SQL Server | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900