pivot error
-
hi everybody . i am trying to use pivot i use northwind data base i try to execute the following sql statement in my sql server management studio SELECT * FROM Orders PIVOT (COUNT(employeeID) FOR employeeID IN ([1],[2],[3],[4],[5],[6],[7],[8],[9])) p but it gives me that error , i don't know what is wrong with the above statement , actually i didn't change the query from the article that i learn from , i copied and pasted it inside the sql management studio i got that error Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '('.
Human knowledge belongs to the world.
-
hi everybody . i am trying to use pivot i use northwind data base i try to execute the following sql statement in my sql server management studio SELECT * FROM Orders PIVOT (COUNT(employeeID) FOR employeeID IN ([1],[2],[3],[4],[5],[6],[7],[8],[9])) p but it gives me that error , i don't know what is wrong with the above statement , actually i didn't change the query from the article that i learn from , i copied and pasted it inside the sql management studio i got that error Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '('.
Human knowledge belongs to the world.
I used this on AdventureWorks (I done't have northwind) and it worked fine. I got the IDs with a select distinct. Dammed if I can see a difference.
SELECT * FROM Sales.SalesOrderHeader
PIVOT (COUNT(SalesPersonID) FOR SalesPersonID IN ([274],[275],[276],[277])) pNever underestimate the power of human stupidity RAH
-
hi everybody . i am trying to use pivot i use northwind data base i try to execute the following sql statement in my sql server management studio SELECT * FROM Orders PIVOT (COUNT(employeeID) FOR employeeID IN ([1],[2],[3],[4],[5],[6],[7],[8],[9])) p but it gives me that error , i don't know what is wrong with the above statement , actually i didn't change the query from the article that i learn from , i copied and pasted it inside the sql management studio i got that error Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '('.
Human knowledge belongs to the world.
Hi, Your Northwind db may not have compatibility level of 90 which is a requirement for the Pivot clause. Try this:
ALTER DATABASE [NorthWind] SET COMPATIBILITY_LEVEL = 90
Hope that helps. Regards,
Syed Mehroz Alam My Blog | My Articles
Computers are incredibly fast, accurate, and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination. - Albert Einstein -
hi everybody . i am trying to use pivot i use northwind data base i try to execute the following sql statement in my sql server management studio SELECT * FROM Orders PIVOT (COUNT(employeeID) FOR employeeID IN ([1],[2],[3],[4],[5],[6],[7],[8],[9])) p but it gives me that error , i don't know what is wrong with the above statement , actually i didn't change the query from the article that i learn from , i copied and pasted it inside the sql management studio i got that error Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '('.
Human knowledge belongs to the world.
It works fine on my machine! I am running Express 2005 but I have the extended Northwind database from http://www.linqdev.com/PublicPortal/publicportal/home.aspx[^].