views:

10

answers:

1

I need to turn the following results...

RowID   ColumnName   Value
======= ============ ==========
200     Status       OK
200     Name         Project 1
200     Created      01/01/2010 00:00
201     Status       FAILED
201     Name         Project 2
201     Created      02/01/2010 18:00
202     Status       OK
202     Name         Project 3
202     Created      03/01/2010 21:00

...into this...

RowID   Status Name      Created
======= ====== ========= ================
200     OK     Project 1 01/01/2010 00:00
201     FAILED Project 2 02/01/2010 18:00
202     OK     Project 3 03/01/2010 21:00

Is this possible?

+2  A: 

There's the PIVOT command...

SELECT *
FROM YourTable
PIVOT (MAX(Value) FOR ColumnName IN ([Status],[Name],[Created])) as p;
Rob Farley