Furthermore naming your stored procedure as sp_[text] will indicate to the sql engine that it is a system stored procedure which is unintended here I guess.
This functionality is IMHO not to be implemented in a stored procedure at all: As it have no side-effects it should be programmed as a function. Doing this will give you...