Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

split columns to rows?

Status
Not open for further replies.

r0brh0des

Programmer
Sep 1, 2006
6
US
I am looking for a way to take the columns for an id to separate rows.

Ex.

Existing Table:

ID COL1 COL2 COL3
1 a b c
2 d e f

Desired Query Result:

ID COL
1 a
1 b
1 c
2 d
2 e
2 f

Thanks!
 
Code:
Select ID, Col1
From   Table

Union All 

Select ID, Col2
From   Table

Union All

Select ID, Col3
From   Table

-George

"the screen with the little boxes in the window." - Moron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top