the usual way of doing this if you've multiple set of where conditions based on parameter values is as followsSET @Sql='SELECT DISTINCT Id FROM [ProductVariant] PRDV WHERE 1 = 1 ' IF(convert(nvarchar(50), @PriceFrom) <> '' AND convert(nvarchar(50), @PriceTo) <> '') SET @Sql1=@Sql1 + ' AND PRDV.Price BETWEEN '+ convert(nvarchar(50), @PriceFrom) +' AND '+ convert(nvarchar(50), @PriceTo)
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs