Incorrect syntax near 'PIVOT'

青春壹個敷衍的年華 提交于 2019-12-01 19:16:58

The possible reason for that type of issue is you imported database from other source which might be running older version of SQL Server. Anyway, you have way to get out of it. Follow steps below:

  1. Right click on Database (e.g. Northwind).
  2. Click 'Properties'.
  3. Click 'Options', from left pane, under 'Select a page' section.
  4. Select appropriate database version as per your installation from drop-down of 'Compatibility level' at right.
  5. Save changes and try now.

Below is screenshot of Properties window for your reference.

Sanja Ž

I had the same error (Incorrect syntax near 'PIVOT'...) and solved it by changing compatibility level in the Options section of database properties.

I also found how to script the compatibility level change:

ALTER DATABASE database_name   
SET COMPATIBILITY_LEVEL = 100

(see https://msdn.microsoft.com/en-us/library/bb510680.aspx?f=255&MSPPError=-2147217396)

i faced the same problem... while using "Pivot" and "Format" and "Convert" command inside sql query.

one thing that worked for me was instead of importing sqlite i imported pyodbc so my code changed

from : import sqlite3 conn = sqlite3.connect('/Users/****/Desktop/****.sqlite')

to: import pyodbc conn = pyodbc.connect('Driver={SQL Server};''Server=@@@@;''Database=****;' 'Trusted_Connection=yes;')

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!