I created a stored procedure based on the example from here on SO. However, I am getting an error. What am I missing here?
CREATE PROCEDURE SFT.usp_GetPrefix
(@p_table VARCHAR(30),
@p_prefix VARCHAR(3) OUTPUT
)
AS
BEGIN
DECLARE @lv_prefix VARCHAR(3);
SELECT @lv_prefix = SUBSTRING(@p_table, 1, 3);
IF(@lv_prefix = 'MAC')
BEGIN
SET @p_prefix = @lv_prefix;
RETURN;
END;
ELSE
SET @p_prefix = 'UNK';
RETURN;
END;
This is how I am executing:
EXEC SFT.usp_GetPrefix @p_table = 'MAC_CHEESE';
Msg 201, Level 16, State 4, Procedure SFT.usp_GetPrefix, Line 0 [Batch Start Line 6] Procedure or function 'usp_GetPrefix' expects parameter '@p_prefix', which was not supplied.
Also tried:
EXEC SFT.usp_GetPrefix @p_table = 'MAC_CHEESE', @p_prefix OUTPUT
Msg 137, Level 15, State 2, Line 6
Must declare the scalar variable "@p_prefix".