views:

42

answers:

3

I have a table with 2 columns:]

ID  Name
1   A
1   B
1   C
1   D
2   E
2   F

And I want write a query to have output like :

1  A  B   C  D
2  E  F

It's possible ?

+2  A: 

You want a Pivot, which is easy in excel, but requires (I believe) quite a bit of work in SQL Server, as it is hard to determine how many columns you need. You could dynamically construct the sql based on a max() aggregate, I suppose.

Start looking here

Luke Schafer