Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Multiple where statements
Message
De
18/02/2005 11:20:22
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00988288
Message ID:
00988369
Vues:
35
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
>>>
>>>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform