Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How do I return columns into rows?

Author  Topic 

madlo
Starting Member

41 Posts

Posted - 2009-03-13 : 02:25:02
Hi,
I am writing a stored proc that I need to use to create a multiline file for me
it needs to return rows of columns off of a sub select statement.
for example
Select ?????
FROM
(
--Multi table join
select Cola,Colb,Colc,Cold,Cole,Colf,Colg from
tab1,tabx
)MyTable
must return me
1,a
2,b
3,c
4,d
5,e
6,f
7,g

so my data is
a1,b1,c1
a2,b2,c2
...
must be returned as
a1
b1
c1
a2
b2
c2
.
.
.

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-03-13 : 02:27:03
unpivot function
Go to Top of Page
   

- Advertisement -