When I run the below procedure with the correct parameters so that the -1 value isn\'t returned, none of my DML statements are firing. I\'m guessing that it\'s treating all my D
In your case (pun intended), you might be better off using a CASE WHEN
construction, seeing you want to evaluate different values for your @Code
variable. MSDN states that CASE
is intended exactly for such scenarios:
Evaluates a list of conditions and returns one of multiple possible result expressions.
I find it makes code a bit more readable for simple evaluations (but that could very well be a personal preference).
Your code would end up looking similar to this (pseudo-code. not tested):
CASE @Code
WHEN 'KP' THEN SET @stringConcat += 'Y';
WHEN 'RL' THEN SET @stringConcat += 'Z';
ElSE
-- Return error code and stop processing
SELECT -1;
RETURN;
END
More on the CASE
statement here:
https://msdn.microsoft.com/en-us/library/ms181765.aspx