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
 General SQL Server Forums
 New to SQL Server Programming
 rows to columns

Author  Topic 

ammyhus
Starting Member

8 Posts

Posted - 2012-01-17 : 07:04:39
hi every one i am trying to convert rows into coulmns would want to know what code to use to achive the same.

i want to convert this .
MDC1201500100;1 023913600018 BOEMARA1
MDC1201500100;1 023913600018 BOEMARA2
MDC1201500100;1 023913600018 BOEMARA3
MDC1201500100;1 023913600018 BOEMARA4

into

MDC1201500100;1 023913600018 BOEMARA1,BOEMARA2,BOEMARA3,BOEMARA4

thanks in advance.




ammyhus
Starting Member

8 Posts

Posted - 2012-01-17 : 07:06:31
sorry i forgot to mention but the final out put has to be in 3 coulmns only.

Thanks & Regards
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-01-17 : 07:10:35
You should be able to use the PIVOT operator. There is documentation and examples here: http://msdn.microsoft.com/en-us/library/ms177410.aspx
Go to Top of Page

ammyhus
Starting Member

8 Posts

Posted - 2012-01-17 : 23:14:01
but doesnt pivot need the values of the measure column. i would appriciate if you could show me how the same would be achived if my measure is an account number feild.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-01-17 : 23:22:46
use the method describe here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -