Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. pivot error

pivot error

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    snouto
    wrote on last edited by
    #1

    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.

    M S I 3 Replies Last reply
    0
    • S snouto

      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.

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      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])) p

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      • S snouto

        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.

        S Offline
        S Offline
        Syed Mehroz Alam
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • S snouto

          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 Offline
          I Offline
          i j russell
          wrote on last edited by
          #4

          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[^].

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups