Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Case in a where?
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01044413
Message ID:
01044430
Vues:
12
It's incorrect use of the CASE function which is designed to return one value based on some conditions. It's similar to VFP IIF() function but more powerfull.
Here how your WHERE clause can be re-written.
	WHERE (@notplinid=1 AND (plinid like @plinid+'%' or @plinid = ''))
		OR (@notplinid <> 1 AND plinid not like @plinid+'%')
>I'll have to check out the SQL execution planning
>
>I know I can do it dynamically very easily...I just thought that doing it without might be faster...I think I'll try both to see if there is any difference.
>
>This is what its suppose to be, but I'm still getting an error at the "like"?
>
> case @notplinid
> when 1 then (plinid like @plinid+'%' or @plinid = '')
> else (plinid not like (@plinid+'%'))
> end
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform