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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Transpose of rows to columns

Author  Topic 

scelamko
Constraint Violating Yak Guru

309 Posts

Posted - 2005-07-08 : 10:34:45
Guys,
I need to transpose my rows to columns.
This is my scenario with sample data

srcdata subid srcdata2 srcdata3
____________________________________________
1000002 1
2000003 2
3000020 3
1000030 1
2000009 2
3000021 3

I want to populate columns srcdata2 and srcdata3 whenever subid = 1 with the values of srcdata
when subid = 2 and 3 respectively

srcdata subid srcdata2 srcdata3
____________________________________________
1000002 1 2000003 3000020
2000003 2
3000020 3
1000030 1 2000009 3000021
2000009 2
3000021 3

Any suggestions/inputs would be very helpful indeed

Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-08 : 10:42:29
This may help you
http://sqlteam.com/searchresults.asp?SearchTerms=pivot

Madhivanan

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

- Advertisement -