Tuesday 14 March 2017

Transpose single column into a single row:

create table #temp(Word varchar(30))
insert into #temp values('word1')
insert into #temp values('word2')
insert into #temp values('word3')
insert into #temp values('word4')
insert into #temp values('word5')

SELECT STUFF((SELECT ' ' + word 
            FROM #temp
            FOR XML PATH('')) ,1,0,'') AS word

No comments:

Post a Comment