Decrease Font Size
Increase Font Size
   BLOG

Incorrect syntax near PIVOT. See help for the stored procedure sp_dbcmptlevel

Msg 325, Level 15, State 1, Line 9 Incorrect syntax near 'PIVOT'. You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel.

Incorrect syntax near 'PIVOT'. You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel.

Why I’m getting this error?
The PIVOT command is not available for SQL Server 2000. When we upgrade the SQL Server 2000 instance to SQL Server 2005, the database COMPATIBILITY_LEVEL remain in 80 until we change it manually.

Solution:

If you are running SQL 2005
EXEC sp_dbcmptlevel 'myDatabaseName', 90

If you are running SQL 2008
EXEC sp_dbcmptlevel 'myDatabaseName', 100

New Syntax as of 02/26/2009:

ALTER DATABASE database_name 
SET COMPATIBILITY_LEVEL = { 80 | 90 | 100 }

http://msdn.microsoft.com/en-us/library/bb510680.aspx

Comments (5) -

  • Tucson Death Records

    11/9/2009 5:00:31 AM |

    We actually got a kick out of your blog post. It seems that you have really placed a bunch of effort into your article and I need more of these on the web these days. I don't really have much to say in reply, I only wanted to register to say well done.

  • posizionamento sito

    3/22/2010 2:53:07 AM |

    I love this blog

  • Dave

    3/27/2010 10:57:12 AM |

    Interesting blog, not like the others!

  • Bill

    3/27/2010 10:59:36 PM |

    Great blog, keeping me from working

  • Mohsin Hassan

    6/22/2012 11:26:24 AM |

    GRet blog ......keep it up

Add comment

Loading