UDFRaiseError

Raises an error from a SQL Server user defined function
  • Free Function
  • SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017

Syntax:

SELECT SQLHTTP.net.UDFRaiseError ( @PROCID, @Message )

Arguments:

Name Type Description
@ProcID int A placeholder for the @@PROCID global variable.
@Message nvarchar(MAX) Error Message to be raised.

Return Type:

bit

Remarks:

SQL Server user defined functions do not allow raising custom errors. This function, as shown in the example below, facilitates this functionality.

Sample Usage:

Msg 6522, Level 16, State 1, Line 27
A .NET Framework error occurred during execution of user-defined routine or aggregate “udf_clr_UDFRaiseError”:
System.Exception:

**************************************
*  Invalid @Weekday parameter value  *
**************************************

System.Exception:
at A..(String )
at UserDefinedFunctions.udf_clr_UDFRaiseError(String Message)

See Also: