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
>>>
>>>