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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 syntax error 'where'

Author  Topic 

chechomir
Starting Member

3 Posts

Posted - 2005-02-19 : 18:36:06
Hi guys,
I am using SQL 2000 server on a windows 2000 server. I have store procedure that was working and now it is giving me an error. The error I get is the following:

[Microsoft][OBDC SQL Server driver][SQL server]incorrect syntax near the keyword 'where'

Does anybody know how to fix this?

Thanks a lot.

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-02-19 : 18:54:27
Let's see ... my magic ball is showing me ... mmmmm .... got it! OK, it on line 25, after the OR, it looks like you have an extra closing parenthesis. Try taking that out, it should do the trick.

- Jeff
Go to Top of Page

chechomir
Starting Member

3 Posts

Posted - 2005-02-19 : 19:00:13
Sorry i forgot the coding. One more clue. I get error when i try to see the BINDINGS in Dreamweaver 2004. I don't get the error in the SQL server.


CREATE PROCEDURE [dbo].[CityStateResultBasic]
@varCity varchar (50),
@varState char (2)
AS
begin
if (@varCity != 'a' and @varState != 'b')
begin
SELECT City, State, ZipCode, TypeofHouse, Sqft, NumberofBeds, Price, NumberofBaths,PropertyID



FROM dbo.tbl_total_prop_info
WHERE City = @varCity and State = @varState
end
else if (@varCity = 'a' and @varState !='b')
begin
SELECT City, State, ZipCode, TypeofHouse, Sqft, NumberofBeds,Price,NumberofBaths, PropertyID
FROM dbo.tbl_total_prop_info
WHERE State = @varState
end
end
GO
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-02-19 : 20:13:27
You already know that there is nothing wrong with the syntax (for sql server).
I know nothing about Dreamweaver but could it be because not all code paths will return a result set? Or it just can't handle the conditional flow of control. I would try using a single Select statement and handle the 2 different where clauses with a case statement.

SELECT City, State, ZipCode, TypeofHouse, Sqft, NumberofBeds,Price,NumberofBaths, PropertyID
FROM dbo.tbl_total_prop_info
WHERE State = @varState
AND City =
Case when @varCity != 'a' and @varState != 'b' then @varCity
Else City
End


Be One with the Optimizer
TG
Go to Top of Page

chechomir
Starting Member

3 Posts

Posted - 2005-02-19 : 20:21:06
Thanks, let me try that.
Go to Top of Page
   

- Advertisement -