Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

What is the easiest way to transpose/pivot one column of data from a table? (sql server 2008)

$
0
0

what is the easiest/simplest way to transpose/pivot this data? (using sql server 2008)

create table #tmpA(fld1 varchar(10))

insert into #tmpA
select 'a' union all
select 'b' union all
select 'c' union all
select 'd' union all
select 'e'

select * from #tmpA

--output
fld1
 a
 b
 c
 d
 e

I need the output to look like this

1  2  3  4  5  --arbitrary column names - just using numbers
a  b  c  d  e

or the output could look like this

1  2  3  4  5
a, b, c, d, e,  --I added a ',' character to each value


Rich P




Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>