I have received this ‘Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch. ---> System.Data.SqlClient.SqlException: Incorrect syntax near '<some Keyword>' error when I migrated my application from SQL server 2005 to SQL server 2008.
What happened is after migration, database compatibility was still set to previous version. So when we ran any SQL script which doesn’t support previous version will throw error.
To resolve this, you just need to login to the SQL server and change the compatibility level.
If you are getting this error while migrating the database from SQL 2000 to SQL 2005 then you may select the option “SQL Server 2005 (90)”
If you are getting this error while migrating the database from SQL 2005 to SQL 2008 then you may select the option “SQL Server 2008 (100)”
If you are a database admin then you can directly open the SQL query analyzer and execute below SQL query,
EXEC sp_dbcmptlevel 'DatabaseName', 90 ---This is for SQL 2005 MigrationEXEC sp_dbcmptlevel 'DatabaseName', 100 --–This is for SQL 2008 Migration
Steps to follow if you are doing it directly on server,
- Login to the database server.
- Locate the database you are getting this error
- Right click on the database and select Properties
- Go to “Options” Page
- Here you will find the option to change the “Compatibility Level”
Below screen print will give you the clear idea of all the options and what you need to change.
You are always welcome to post your comments below.
No comments:
Post a Comment