在存储过程中触发错误

https://docs.microsoft.com/en-us/sql/t-sql/language-elements/raiserror-transact-sql

Generates an error message and initiates error processing for the session.

RAISERROR can either reference a user-defined message stored in the sys.messages catalog view or build a message dynamically.

The message is returned as a server error message to the calling application or to an associated CATCH block of a TRY…CATCH construct.

New applications should use THROW instead.  

 

https://docs.microsoft.com/en-us/sql/t-sql/language-elements/throw-transact-sql

SQL Server (starting with 2012)

Raises an exception and transfers execution to a CATCH block of a TRY…CATCH construct in SQL Server 2017.

posted @ 2018-03-02 10:44  ChuckLu  阅读(264)  评论(0编辑  收藏  举报