June 2, 2014 at 9:05 am
Hi,
I am running sqlserver 2012.
My output data is like
COL1
aaa
bbb
ccc
Now, i want to convert the output to
aaa;bbb;ccc
How can i do this?
June 2, 2014 at 9:18 am
Read the following article to find out how to do it.
http://www.sqlservercentral.com/articles/comma+separated+list/71700/
June 2, 2014 at 9:38 am
create table #TestData (Col1 varchar(20))
insert into #TestData
select 'aaa' union all
select 'bbb' union all
select 'ccc'
select stuff((select ','+Col1
from #TestData
order by col1
for xml path(''))
,1,1,'') as delimitedlist
Edited:
Whups, you were too quick for me Luis. Yes, that article is a better reference.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply