Restore SQL Server 2008 R2 database to SQL Server 2012 and getting syntax errors

147 views Asked by At

My application is working on SQL Server 2008 R2 and I need to move it to SQL Server 2012, so first I restored the database backup on SQL Server 2012 and then set compatibility level to 100, but RAISEERROR syntax errors are showing up which are related to triggers. There are so many triggers in the database, do I have to amend each and every trigger manually or what should be its best approach?

ALTER DATABASE YourDatabaseName SET COMPATIBILITY_LEVEL = 100
1

There are 1 answers

0
Mazhar On

I'm assuming the code is using the undocumented version of RAISEERROR that is no longer supported in 2012+

replace anything like this

RAISERROR 9999 'User already exists.'

to something like this

DECLARE @ERRMSG NVARCHAR(100) = 'User already exists.', @ErrorSeverity INT = 9999
RAISERROR (@ERRMSG,@ErrorSeverity,1 )