I’m writing a store procedure that needs to perform a SWITCH of a string variable and doing something different depending on the value, a pseudo-code could be:
CASE @my_string
WHEN 'value'
UPDATE table 1
WHEN 'Other_value'
UPDATE table 2
I can’t find any example of a switch done in this way, is it possible or do I need to use IF/ELSE everytime?
Thank you
Using
IFwould be the typical way: