I am familiar using Case in a Select statement, etc.
But I am unsure how to use it to execute code, like using it instead of an If statement.
Does anyone know if it's possible? I tried this, but doesn't work:
CASE @Variable
WHEN 0 THEN
SELECT * FROM TABLE1
...
BREAK;
WHEN 1 THEN
SELECT * FROM TABLE2
...
BREAK;
END
In other words, I should get this functionality:
if(@Variable=1) SELECT * FROM TABLE1
if(@Variable=2) SELECT * FROM TABLE2
But using a case statement for the argument.
This is a sample of code, so please do not take it literally. The objective is find out if you can use CASE statements in the same manner as a IF
THEN
statement. Like using switch
in c#