krishna
krishna

Reputation: 1199

Migrating from SQL Server 2008r2 to SQL Sever 2012

RAISEERROR not supported in SQL Server 2012

RAISERROR 44444 'Field ''CostCodeId'' cannot contain a null value.'

How to change the syntax to make it to support in sql server 2012. Any alternative please help.

Upvotes: 2

Views: 478

Answers (2)

Manoj Pandey
Manoj Pandey

Reputation: 1397

For any new development work start using THROW, and if possible start replacing RAISERROR with THROW, as it can be replaced anytime in future (but I don't think in near future).

RAISERROR was deprecated in SQL Server 2012 and replaced by THROW, and it may be completely replaced by THROW in new versions of SQL Server.

With RAISERROR it was mandatory to provide the parameters like error_message, error_number, error+severity, but with THROW all there are optional. THROW gets all this information from the new and improved error handling mechanism and returns the information to the user in case of any exception.

Upvotes: 0

Tak
Tak

Reputation: 1562

In SQL 2012 you should use THROW.

Here is link New THROW statement in SQL Server 2012

Upvotes: 1

Related Questions