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!

Transform rowvalue into columnheader 1

Status
Not open for further replies.

onwagena

Technical User
Jan 11, 2004
8
NL
I have a table with 2 columns:

Column1 Column2
----- ------------
Aa TextA
Bb TextB
Cc TextC

And I must transform this to an new table like this:

Aa Bb Cc
----- ----- -----
TextA TextB TextC

The values of column1 must be the columnheader in the new table

The select statement must be so dynamic that when there is a new record in the original table there must be a new column in the new table.

Aa Bb Cc Dd
----- ----- ----- ------
TextA TextB TextC TextD

How can I solve this problem?
 
Take a look at PIVOT and UNPIVOT. Should get you started down the right path.

--------------------------------------------------
“Crash programs fail because they are based on the theory that, with nine women pregnant, you can get a baby a month.” --Wernher von Braun
--------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top