sql query to show results vertically

user194076 picture user194076 · Apr 21, 2012 · Viewed 10.1k times · Source

How to transform this:

ID   Name    Description
1    Test1a   TestDesc1a
1    Test1b   TestDesc1b
2    Test2a   TestDesc2a
2    Test2b   TestDesc2b

into this:

ID   Column          1            2
1    Name          test1a       test1b
1    Description   testDesc1a   testDesc1b

Answer

mordka picture mordka · Apr 21, 2012

You ask for complex pivoting table. Read about this here: http://msdn.microsoft.com/en-us/library/ms177410.aspx