The case statement will not trim it: the only way to use SET with CASE is:
SET @var = CASE @check WHEN 'abc' THEN @value [etc] END
... which will not work for you, as this can only set one variable. Therefore, you need to use ELSE, i.e.:
IF (@check = 'abc') SET @var1 = @value ELSE IF (@check = 'def') SET @var2 = @value ELSE IF (@check = 'ghi') SET @var3 = @value ELSE IF (@check = 'jkl') SET @var4 = @value ELSE IF (@check = 'mno') SET @var5 = @value [...]
However, if you have 100 sentences, such as this parameter, 100 different variables, then it looks like your approach might be wrong: I would take a step back and ask myself why you need 100 separate variables. Perhaps something is better than what you can do as a set-based solution, either reading from the main or temporary tables. However, we will need more detailed information about what you are trying to do (with a small but fully working example).
source share