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 2005 Forums
 Transact-SQL (2005)
 getting incorrect syntax near the BETWEEN

Author  Topic 

sqldev6363
Yak Posting Veteran

54 Posts

Posted - 2011-08-10 : 21:26:29
select a.id, a.fromDate,b.toDate from AA a
Left Outer Join BB b
ON a.id = b.id
AND (DateDiff(hh,a.fromDate,b.toDate) between 0 and 4)

IS the above statement is true or need to change anything?

i am getting this error "getting incorrect syntax near the keyword BETWEEN"

Thanks in advance

dev

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-08-10 : 21:46:15
i don't see any problem with that query. Can you post the complete error message ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

sqldev6363
Yak Posting Veteran

54 Posts

Posted - 2011-08-10 : 21:49:00
Here it is
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'between'.

quote:
Originally posted by khtan

i don't see any problem with that query. Can you post the complete error message ?


KH
[spoiler]Time is always against us[/spoiler]





dev
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-08-10 : 21:51:24
That is the actual query you execute that gives the error message ?




KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

sqldev6363
Yak Posting Veteran

54 Posts

Posted - 2011-08-10 : 23:22:56
YES

quote:
Originally posted by khtan

That is the actual query you execute that gives the error message ?




KH
[spoiler]Time is always against us[/spoiler]





dev
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-08-10 : 23:32:22
i have tried to execute that query in my environment but i don't get any error message at all.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -