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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rows to Columns 1

Status
Not open for further replies.

xxing

Programmer
Feb 17, 2004
61
NZ
Hi

I have a table that has rows which I want to convert to columns

e.g.

#Fruit
COL1
Apple
Pear
Orange

I want a table that has
COL1 COL2 COL3
Apple Pear Orange

The #Fruit table can have 3 or more rows.
The names of the fruit can differ

Can this be done?

Thank you
Mark

 
if you have sql 2005 you can use the pivot command does exactly what you need

no point in me retyping - here is a good link explains it all
[link]http://technet.microsoft.com/en-us/library/ms177410.aspx[/url]


"I'm living so far beyond my income that we may almost be said to be living apart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top