How to display all row data in single string
HOW TO DISPLAY ALL ROW DATA IN SINGLE STRING :
SELECT Stuff(
(SELECT N', ' + Name FROM [TableName] FOR XML PATH(''),TYPE)
.value('text()[1]','nvarchar(max)'),1,2,N'')
Output :
ACBCK12..1212sid...
EX:
SELECT Stuff(
(SELECT N', ' + Name FROM Test FOR XML PATH(''),TYPE)
.value('text()[1]','nvarchar(max)'),1,2,N'')
output :
Nihar, Rohan, Rohan, , Sw, Sw
SELECT Stuff(
(SELECT N', ' + Name FROM [TableName] FOR XML PATH(''),TYPE)
.value('text()[1]','nvarchar(max)'),1,2,N'')
Output :
ACBCK12..1212sid...
EX:
SELECT Stuff(
(SELECT N', ' + Name FROM Test FOR XML PATH(''),TYPE)
.value('text()[1]','nvarchar(max)'),1,2,N'')
output :
Nihar, Rohan, Rohan, , Sw, Sw
Comments
Post a Comment