Not sure how to do this...
I have a stored procedure that is similar to this:
Create Procedure sp_search
(@search_items varchar(50),
@price1 decimal(9,2),
@price2 decimal(9,2),
@method varchar(10))
AS
I am not sure to how handle this.
If @method has no value then I want this search:
select * from product where CONTAINS(csearch_items,@se
arch_items
)
If @method has the value 'equal' then I want this search:
select * from product where CONTAINS(csearch_items,@se
arch_items
) AND price = @price1
If @method has the value 'greater' then I want this search:
select * from product where CONTAINS(csearch_items,@se
arch_items
) AND price > @price1
If @method has the value 'less' then I want this search:
select * from product where CONTAINS(csearch_items,@se
arch_items
) AND price < @price1
If @method has the value 'range' then I want this search:
select * from product where CONTAINS(csearch_items,@se
arch_items
) AND ((price > @price1) AND (price < @price2))
Start Free Trial