Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Stored procedure

Author  Topic 

suarezst1984
Starting Member

16 Posts

Posted - 2009-05-06 : 15:44:32
Ican't see anything wrong with this part of the stored procedure but I still get an error "Incorrect Syntax near keyword "and" '

IF (@pricestart <> 0.00 OR @price_end <> 10000.00) AND @shortTerm = 0
BEGIN
SELECT @searchString = @searchString + ' AND ((Cast(sfProducts.prodPrice AS float) BETWEEN ' + CAST(@pricestart AS varchar) + ' AND ' + CAST(@price_end AS varchar)
+ ' AND sfProducts.prodSaleIsActive = 0)
OR (Cast(sfProducts.prodSalePrice AS float) BETWEEN ' + CAST(@pricestart AS varchar) + ' AND ' + CAST(@price_end AS varchar) + 'AND sfProducts.prodSaleIsActive = 1)) '
END

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-06 : 15:50:02
It checks out fine for me. Perhaps you should post the entire thing as the line number it complains about is not always the correct line number.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -