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
>
>
>>After two years I am back doing SQL Server, I don't mind.
>>
>>
>>My first asignment is to create a report for one of the cost centers or two of the cost centers depending on if 'ALL','SMS', or 'SMP' is inputed by the user.
>>
>>I made a view with just 'SMS' and 'SMP' in it.
>>
>>What is the best way to handle this, I have been using brute force i.e.
>>
>>
>>if @cost_center = 'ALL'
>>
>>Begin
>>SELECT *
>>FROM vw.foo f
>>END
>>
>>ELSE
>>
>>BEGIN
>>
>>SELECT *
>>FROM vw.foo f
>>WHERE f.cost_center = @cost_center
>>
>>END
>>
>>Is there a better way?