SQL SERVER – Fix : Error : Incorrect syntax near . 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

I have seen developer confused many times when they receive following error message.

Msg 325, Level 15, State 1, Line 7
Incorrect syntax near . 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.

The reason for this error is when user is tring to attempt to run query or procedure or logic which is not compatible with previous version of the SQL Server. When SQL Server 2000 is upgraded to SQL Server 2005 or SQL Server 2008, the database object compatibility should be also upgraded to next version. When database compatibility is set to previous version and they are attempted with procedure of newer version they will throw above error.

Fix/Workaround/Solution:

Change the database compatibility level using following command.

For SQL Server 2005:

EXEC sp_dbcmptlevel 'DatabaseName', 90

For SQL Server 2008:

EXEC sp_dbcmptlevel 'DatabaseName', 100

Reference : Pinal Dave (https://blog.sqlauthority.com)

Solarwinds
, , , ,
Previous Post
SQL SERVER – Transaction and Local Variables – Swap Variables – Update All At Once Concept
Next Post
SQLAuthority News – Running SQL Server 2008 in a Hyper-V Environment Best Practices and Performance Considerations

Related Posts

86 Comments. Leave new

Leave a Reply

Menu