SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 convert row to the column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mtvaran
Starting Member

United Kingdom
1 Posts

Posted - 11/12/2010 :  23:58:54  Show Profile  Reply with Quote
Hi guys, i have a big problem of creating row as a column.
Ex:

id | name
1 | A
2 | B
3 | C

i want to change as this...

A | B | C
1 | 2 | 3

i know for you guys, this is not a big issue! could anyone please help me?
thank you

chadmat
The Chadinator

USA
1974 Posts

Posted - 11/14/2010 :  03:06:39  Show Profile  Visit chadmat's Homepage  Reply with Quote
Look up Pivot in Books Online

-Chad
Go to Top of Page

bklr
Flowing Fount of Yak Knowledge

India
1693 Posts

Posted - 11/15/2010 :  05:12:12  Show Profile  Reply with Quote
or try like this too
select max(case when name = 'A' then id end) as 'A',
max(case when name = 'B' then id end) as 'B',
max(case when name = 'C' then id end) as 'C'
from table name
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.22 seconds. Powered By: Snitz Forums 2000