Decrease Font Size
Increase Font Size
   BLOG

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

by Admin 29. July 2009 15:02

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

Tags: , , ,

SQL

Comments

11/11/2009 12:00:31 PM #

Tucson Death Records

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.

Tucson Death Records

3/24/2010 9:53:07 AM #

posizionamento sito

I love this blog

posizionamento sito Libya

3/29/2010 5:57:12 PM #

Dave

Interesting blog, not like the others!

Dave Czech Republic

3/30/2010 5:59:36 AM #

Bill

Great blog, keeping me from working

Bill Latvia