Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multiple where statements
Message
From
18/02/2005 11:20:22
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00988288
Message ID:
00988369
Views:
36
Okay what if I had two variables?
Here is my actual code.

I am using this in the query analyzer to test
before making it into a procedure.
They chose between cost centers SMS, SMP, or ALL
And if the item is active or inactive.

I read the books online but it doesn't
show case statements for multiple variables

Thanks again
Jim




DECLARE @item_status as varchar(50)
DECLARE @cost_center as varchar(3)

SET @cost_center = 'SMS'
SET @item_status = 'InActive'


SELECT

*

FROM

vw_SMPaper_Inventory_Activity_Detail smp

WHERE smp.item_cost_center LIKE
CASE WHEN( @cost_center = 'ALL') THEN '%' ELSE @cost_center END






>You're welcome.
>
>>WOW!
>>That was clean and beautiful!
>>Thanks Sergey
>>
>>>Try
>>>SELECT *
>>>  FROM vw.foo  f
>>>  WHERE f.cost_center LIKE
>>>    CASE WHEN @cost_center = 'ALL' THEN '%' ELSE @cost_center END
>>>
>>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform