Based on the comment:
I misspoke on the error message (did it from memory on another PC). Here is the actual error message: Msg 245, Level 16, State 1, Line 8 Conversion failed when converting the varchar value ''Display these other words ' to data type int. So, the error message is that it thinks the text (to display) is a data type that needs to be converted. Any ideas?
Your issue (which could have been much easier to figure out, had the actual code and error been posted)
Declare @Var1 ...
Is actually Declare @var1 int
.
so your statement:
'Display this sentence ' + @Var1 +'followed by there words '
is failing for:
Conversion failed when converting the varchar value ''Display these other words ' to data type int.
You simply need to convert/cast @Var1
to varchar
for that part of your case statement.
WHEN 'Display this sentence ' + convert(varchar(14), @Var1) +'followed by there words '
The reason you're seeing this behavior (taken from here is:
You need to explicitly convert your parameters to VARCHAR before trying to concatenate them. When SQL Server sees @my_int (@Var1 in your case) + 'X' it thinks you're trying to add the number "X" to @my_int (@Var1) and it can't do that.
Another option is concat.
WHEN concat('Display this sentence ', @Var1, ' followed by there words ')