Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Question about the CASE statement
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00716871
Message ID:
00716912
Vues:
17
>Can I set a variable within the CASE statement? I keep getting a syntax error when trying to set a variable within a CASE statement. I need to set a variable at the row level.

Probably the reason that you're having an issues is that CASE is an expression.

SET @var = CASE WHEN 1 THEN 'a' WHEN 2 THEN 'b' ELSE 'c' END

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform