Introduction:-
in this article we will learn how to convert multiple row into one comma separator.
Example:-
I have table that contain the skill data . now convert it comma separated form.
in this article we will learn how to convert multiple row into one comma separator.
Example:-
I have table that contain the skill data . now convert it comma separated form.
Synatx:-
1.
Declare @tmp varchar(250)
SET @tmp = ''
select @tmp = @tmp + ColomnName + ', ' from TableName
select SUBSTRING(@tmp, 0, LEN(@tmp))
2.
select
stuff((
SELECT ',' + ColomnName
FROM TableName
for xml path('')
1. ),1,1,'') as name_csv
No comments:
Post a Comment