question

aroradhruv73 avatar image
aroradhruv73 asked

Converting rows into columns

Hi I have a table Code Colour Desc ---------------------- D Blue ABC E1 Green DEF L Red GHI I Yellow JKL I want the result like the this: Code1 Colour1 Desc1 Code2 Colour2 Desc2 Code3 Colour3 Desc3 Code4 Colour4 Desc4 ------------------------------------------------------------------------------- D Blue ABC E1 Green DEF L Red GHI I Yellow JKL
sqlpivotcrosstab
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Naveen Kumar avatar image
Naveen Kumar answered
DECLARE @Horizontal varchar(max) select @Horizontal = coalesce(@Horizontal + ' ',' ') + code1 + ' '+ color1 + ' '+ desc1 from color select @Horizontal
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.