Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (40.7k points)

In SQL Server 2000 and 2005:

what is the difference between these two WHERE clauses?

which one I should use on which scenarios?

Query 1:

SELECT EventId, EventName

FROM EventMaster

WHERE EventDate BETWEEN '10/15/2009' AND '10/18/2009'

Query 2:

SELECT EventId, EventName

FROM EventMaster

WHERE EventDate >='10/15/2009'

  AND EventDate <='10/18/2009'

(Edit: the second Eventdate was originally missing, so the query was syntactically wrong)

1 Answer

0 votes
by (40.7k points)

You can use another longer syntax where BETWEEN doesn't work.

For example:

Select EventId,EventName from EventMaster

where EventDate >= '10/15/2009' and EventDate < '10/18/2009'

(Note < rather than <= in second condition.)

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...