In a stored procedure, I am trying to test if a parameter is null or less then 1, and if so, raise an error with a friendly message, and the value of the parameter.
Here is my code:
IF @ID IS NULL OR @ID <= 0
BEGIN
RAISERROR 27001 'ID is ?????. ID cannot be null or less then zero.'
RETURN 27001
END
What I would like back is either:
"ID is 0. ID cannot be null or less then zero." or "ID is null. ID cannot be null or less then zero."
I've tried building a varchar and raising the error like this:
RAISERROR 27001 @message
but that produces the error "Message Number 27001, passed to RAISERROR, does not exist in the sysmessages catalog."