Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Case in a where?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01044413
Message ID:
01044430
Views:
13
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--
Previous
Reply
Map
View

Click here to load this message in the networking platform