SQL Server 2005, turn columns into rows

后端 未结 6 929
广开言路
广开言路 2020-12-10 06:50

I am trying to turn a table 90 degrees: make columns rows. No PIVOT is allowed since PIVOT requires aggregate functions.

Example: I have a table with the columns

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-10 07:15

    If you try this solution and get a syntax error try setting the compatability mode of your database via

    ALTER DATABASE myDatabase SET COMPATIBILITY_LEVEL = 90;
    

    This will set the compatability to SQLServer 2005 and the above queries will execute w/o a syntax error.

提交回复
热议问题