Joe_Fox type SQL question

Log in to stop seeing adverts
This page may contain links to companies such as eBay and Amazon. As an affiliate of these sites I may earn commission if you click the link and make a purchase

Status
Not open for further replies.

Matt_B

Well-Known Member
I have a table of one row (it's actually a view, don't ask why I have a table with only one row)

Code:
Col 1, Col 2, Col 3, Col 4
12, 234, 25, 290

What I want to end up with, using SQL is

Col1, 12
Col2, 234
Col3, 25
Col4, 290

So turn 1 row into however many rows there are columns, with the single row value as the second column

I believe maybe cross join, cross apply or pivot tables may do this, but I can't for the life of me get it to work.
 
:)

PIVOT does it the other way round

there's an un-pivot transformation in SSIS...
 
I have 25 working days left until I never had to programme or touch SQL again, I can't wait.
 
Status
Not open for further replies.
Log in to stop seeing adverts

P Pld Pts
1Liverpool1639
2Chelsea1735
3Arsenal1733
4Nottm F1731
5Bournemouth1728
6Aston Villa1728
7Manchester C  1727
8Newcastle1726
9Fulham1725
10Brighton1725
11Tottenham 1723
12Brentford1723
13Manchester U1722
14West Ham1720
15Everton1616
16Palace1716
17Leicester1714
18Wolves1712
19Ipswich1712
20Southampton176

Latest posts

Back
Top