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
 Error in SQL statement

Author  Topic 

scmay
Starting Member

22 Posts

Posted - 2007-08-08 : 20:57:06
DECLARE CareModel_cursor cursor FOR SELECT DISTINCT ObAnteEvent.UrNo
FROM ObBabyEpisode INNER JOIN ObAnteEvent ON
ObAnteEvent.UrNo = ObBabyEpisode.UrNo AND ObAnteEvent.EpisodeID = ObBabyEpisode.EpisodeID
WHERE ObAnteEvent.EventType='CareModel' ORDER BY EventDate,EventTime
AND CONVERT(DateTime,ObBabyEpisode.BirthDate,103)>= Convert(DateTime,'1/1/2000',103)
AND CONVERT(DateTime, ObBabyEpisode.BirthDate,103)<= Convert(DateTime,'1/1/2007',103)

Error is at 'AND ObAnteEvent.EpisodeID = ObBabyEpisode.EpisodeID' Why is this a problem and how do I solve this?

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-08-08 : 21:07:43
What was the error message? What's sql version and sp level?
Go to Top of Page

scmay
Starting Member

22 Posts

Posted - 2007-08-08 : 21:08:49
Server: Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'AND'.
SQL 2000/SQL Express 2005 gave same error.
sp level? What is that.?
Go to Top of Page

scmay
Starting Member

22 Posts

Posted - 2007-08-08 : 21:33:30
error found.wrong location of ORDER BY
Go to Top of Page
   

- Advertisement -