I can't believe I wasn't able to find the solution in other posts, but here goes..
I am trying to update different tables depending on a set variable, and I'd like the structure to be this way:
IF @etape = 1
(UPDATE table1 SET column1 = 1)
IF @etape = 2
(UPDATE table2 SET column1 = 1)
ELSE
(SELECT 'Wrong choice')
I have tried using CASE:
CASE WHEN @etape = 1 THEN
(UPDATE table1 SET column1 = 1)
WHEN @etape = 2 THEN
(UPDATE table2 SET column1 = 1)
ELSE
(SELECT 'Wrong choice')
END
Although the documentation doesn't mention this, it seems like only SELECT statements are allowed after IF or CASE. Would appreciate some help here.
Aucun commentaire:
Enregistrer un commentaire