Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 insert problem

Author  Topic 

mitasid
Yak Posting Veteran

51 Posts

Posted - 2006-06-14 : 19:23:31
Hi i want to convert rows to columns in my table.
my rows are jan,feb,mar,apr,.....dec
i want to convert them into columns

how shall i do that?????

nosepicker
Constraint Violating Yak Guru

366 Posts

Posted - 2006-06-14 : 20:39:46
Use the CASE statement:

SELECT
CASE WHEN YourColumn = 'jan' THEN ... END AS [jan],
CASE WHEN YourColumn = 'feb' THEN ... END AS [feb],
...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-15 : 03:00:48
Read about Cross-tab Reports in sql server help file
Also refer
http://weblogs.sqlteam.com/jeffs/archive/2005/05.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -