I have a stored procedure that does some parameter validation and should fail and stop execution if the parameter is not valid.
My first approach for error checking look
We normally avoid raiseerror() and return a value that indicates an error, for example a negative number:
if
return -1
Or pass the result in two out parameters:
create procedure dbo.TestProc
....
@result int output,
@errormessage varchar(256) output
as
set @result = -99
set @errormessage = null
....
if
begin
set @result = -1
set @errormessage = 'Condition failed'
return @result
end