The Throw command does not have the exception severity parameter, the exception severity is always set to 16.
Raises an exception and transfers execution to a CATCH block of a TRY ... CATCH construct in SQL Server 2012.
[ {error_number | @local_variable}, {message | @local_variable}, ][ ]
Arguments
-
-
Error_number
-
-
is a constant or variable that represents the exception. Error_number is int and must are greater than or equal to 50000 and less than or equal to 2147483647.
-
-
message
-
-
is a string or variable that describes the exception. message is nvarchar (2048).
-
-
State
-
-
is a constant or variable between 0 and 255 that indicates the state to associate with the message. State is tinyint.
Remarks
If a TRY ... CATCH construct is not available and the session is ended. The line number and procedure where the exception was raised are set. The severity is set to.
If The THROW statement is specified without parameters, it must appear inside a CATCH block. This causes the caught exception to be raised. Any error This occurs in a THROW statement causes the statement batch to be ended.
State's role: if you raise the same user-defined error in more than one location, using a unique status number for each location helps you find the snippet that caused the error.
Examples
51000 ' The record does not exist. ' 1;
Reference Documentation:
THROW (Transact-SQL)
Throw an error message with throw