Migrating from SQL Server 2008r2 to SQL Sever 2012

假如想象 提交于 2019-12-12 17:38:37

问题


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.


回答1:


In SQL 2012 you should use THROW.

Here is link New THROW statement in SQL Server 2012




回答2:


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.



来源:https://stackoverflow.com/questions/26908329/migrating-from-sql-server-2008r2-to-sql-sever-2012

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!