I'd like to take the result of a stored procedure and concatenate it with additional text in as simple a way as possible.
Something along these lines:
Stored procedure:
CREATE PROCEDURE [dbo].[sp_UserFriendlyText] @Text varchar(100)
AS
BEGIN
SELECT CASE @Text
WHEN 'Foo' THEN 'Beginning'
WHEN 'bar' THEN 'End'
ELSE 'Text Not Found'
END
END
It would be referenced like so:
DECLARE @Var1 varchar(100)
SET @Var1 = 'Foo'
EXEC dbo.sp_UserFriendlyText @Var1 + ' is the best'
With the desired result being "Beginning is the best".
It complains my syntax is incorrect. I've tried adding parenthesis around the exec statement to create precedence, but it still doesn't work.
Because the sproc will be referenced in multiple queries I'd like to run it without the output declaration if at all possible (just to make things cleaner).
System is SQL Server 2008 R2.
Thanks!